public void TestReverseWithMultipleCharachters() { var target = new StringHelper(); var result = target.Reverse("ab"); Assert.AreEqual("ba", result); }
/// <summary> /// </summary> /// <param name="reader"></param> public ILTokenizer (StreamReader reader) { this.reader = new ILReader (reader); strBuilder = new StringHelper (this); numBuilder = new NumberHelper (this); lastToken = ILToken.Invalid.Clone () as ILToken; }
static void Main(string[] args) { ConsoleManager = new ConsoleManager(); ExcelLogger = new ExcelLogger(); FilePerVehicleLogger = new FilePerVehicleLogger(ConsoleManager); HtmlLogger = new HtmlLogger(FilePerVehicleLogger, ConsoleManager); JsonLogger = new JsonLogger(FilePerVehicleLogger, ConsoleManager); WebCrawler = new WebCrawler(ConsoleManager); StringHelper = new StringHelper(); Logger = new Logger(JsonLogger, HtmlLogger, StringHelper, ConsoleManager); DataProcessor = new DataProcessor(ConsoleManager, StringHelper, WebCrawler, ExcelLogger, Logger); GroundForcesScraper = new GroundForcesScraper(WebCrawler, ConsoleManager); try { overallStopwatch.Start(); ConsoleManager.WriteProgramTitleVersionAndInitialBlurb(); ConsoleManager.WriteInputInstructionsAndAwaitUserInput(ConsoleColor.Yellow, ConsoleKey.Enter, "Press ENTER to begin."); // Load Wiki Home page HtmlDocument groundForcesWikiHomePage = GroundForcesScraper.GetGroundForcesWikiHomePage(); // Crawl ground forces // TODO: Move of these parameters can be moved into DataProcessor as they aren't used againw DataProcessor.CrawlWikiSectionPagesForData(groundForcesWikiHomePage, vehicleWikiPagesContent, localFileChanges, vehicleDetails, errorsList, overallStopwatch, CreateJsonFiles, CreateHtmlFiles, CreateExcelFile); ConsoleManager.WriteExitInstructions(); } catch (Exception ex) { ConsoleManager.WriteException($"The following exception was encounted: {ex.Message}\r\nException details: {ex.StackTrace}"); } }
public void TestWithAccents() { var target = new StringHelper(); var result = target.Reverse("Les Misérables"); Assert.AreEqual("selbarésiM seL", result); }
public Craken(int _stackSize = 1024) { stackSize = _stackSize; StrHelp = new StringHelper(); ExprHelp = new ExpressionHelper(this); objects = new Dictionary<string, CrakenObject>(); functions = new Dictionary<string, Function>(); scripts = new Dictionary<string, Script>(); stack = new Stack(stackSize); }
public void TestReverse() { // Arrange var target = new StringHelper(); // Act string result = target.Reverse("a"); // Assert Assert.AreEqual("a", result); }
public void ReverseStringTest() { // Arrange var stringHelper = new StringHelper(); var inputString = "ASDFGQWERTY"; var expectedResult = "YTREWQGFDSA"; // Act var result = stringHelper.ReverseString(inputString); // Assert Assert.AreEqual(expectedResult, result); }
public void WordCountTest() { // Arrange var stringHelper = new StringHelper(); var inputString1 = "the night is dark and full of terrors"; var expectedResult1 = 8; var inputString2 = "winter is coming"; var expectedResult2 = 3; // Act var result1 = stringHelper.WordCount(inputString1); var result2 = stringHelper.WordCount(inputString2); // Assert Assert.AreEqual(expectedResult1, result1); Assert.AreEqual(expectedResult2, result2); }
private static void Main(string[] args) { // string mess = "Allo"; var stringHelper = new StringHelper(); // DELGATE // var d1 = new Delegate1(stringHelper.CountMes); // var d2 = new Delegate1(stringHelper.CountA); // ShowNum(d1, mess); // ShowNum(d2, mess); // Common DELEGATE // stringHelper.Waiting = Show; // stringHelper.WaitForSec(10); stringHelper.WaitingEvent += WaitingEvent; stringHelper.WaitForSecEvent(3); Console.ReadLine(); }
public int GetSCIDByName(string categoryName) { int scid = 0; string sqlStr = "select * from SurveyCategory where Status=-3 and Name='" + StringHelper.SqlFilter(categoryName) + "'"; DataSet ds = SqlHelper.ExecuteDataset(CONNECTIONSTRINGS, CommandType.Text, sqlStr); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { int.TryParse(ds.Tables[0].Rows[0]["SCID"].ToString(), out scid); } return(scid); }
public static List <LogInfo> FileDelete(EngineState s, CodeCommand cmd) { List <LogInfo> logs = new List <LogInfo>(); CodeInfo_FileDelete info = cmd.Info.Cast <CodeInfo_FileDelete>(); string filePath = StringEscaper.Preprocess(s, info.FilePath); Debug.Assert(filePath != null, $"{nameof(filePath)} != null"); // Path Security Check if (!StringEscaper.PathSecurityCheck(filePath, out string errorMsg)) { return(LogInfo.LogErrorMessage(logs, errorMsg)); } // Check srcFileName contains wildcard string wildcard = Path.GetFileName(filePath); if (!StringHelper.IsWildcard(wildcard)) { // No Wildcard if (File.Exists(filePath)) { // Delete File File.SetAttributes(filePath, FileAttributes.Normal); File.Delete(filePath); logs.Add(new LogInfo(LogState.Success, $"Deleted file [{filePath}]")); } else { logs.Add(new LogInfo(info.NoWarn ? LogState.Ignore : LogState.Warning, $"File [{filePath}] does not exist")); } } else { // With Wildcard // Use FileHelper.GetDirNameEx to prevent ArgumentException of Directory.GetFiles string srcDirToFind = FileHelper.GetDirNameEx(filePath); if (!Directory.Exists(srcDirToFind)) { return(LogInfo.LogErrorMessage(logs, $"Cannot find path [{srcDirToFind}]")); } string[] files = FileHelper.GetFilesEx(srcDirToFind, wildcard, info.NoRec ? SearchOption.TopDirectoryOnly : SearchOption.AllDirectories); if (files.Length == 0) { logs.Add(new LogInfo(info.NoWarn ? LogState.Ignore : LogState.Warning, $"Files matching wildcard [{filePath}] were not found")); return(logs); } s.MainViewModel.SetBuildCommandProgress("FileDelete Progress", files.Length); try { for (int i = 0; i < files.Length; i++) { string f = files[i]; s.MainViewModel.BuildCommandProgressText = $"{f}\r\n({(double)(i + 1) / files.Length * 100:0.0}%)"; // Prevent exception from readonly attribute File.SetAttributes(f, FileAttributes.Normal); File.Delete(f); s.MainViewModel.BuildCommandProgressValue = i + 1; logs.Add(new LogInfo(LogState.Success, $"File [{f}] deleted")); } logs.Add(new LogInfo(LogState.Success, $"[{files.Length}] files deleted")); } finally { s.MainViewModel.ResetBuildCommandProgress(); } } return(logs); }
public JSValue GetProperty(string propertyName) { StringHelper propertyNameStr = new StringHelper(propertyName); return(new JSValue(awe_jsobject_get_property(instance, propertyNameStr.value()))); }
public void WriteLog(int uid, string info) { using (IDbConnection conn = SqlString.GetSQLiteConnection()) { conn.Execute("INSERT INTO sys_log(UserId,LogInfo,CreateTs)" + "VALUES(@UserId,@LogInfo,@CreateTs)", new { UserId = uid, LogInfo = info, CreateTs = StringHelper.GetTimeStamp() }); } }
void ctrl_Leave(object sender, EventArgs e) { unLockExcel(); 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; if (lp.CtrlType.Contains("uc_gridcontrol")) { FillTable(ea, lp, (sender as uc_gridcontrol).GetContent(String2Int(lp.WordCount.Split(pchar)))); LockExcel(); return; } else if (lp.CtrlType.Contains("DevExpress.XtraEditors.DateEdit")) { FillTime(ea, lp, (sender as DateEdit).DateTime); LockExcel(); 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]); 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]); } } LockExcel(); 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]); LockExcel(); 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]); 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 (ctrlOrgName != null) ctrlOrgName.Text = str; if (list.Count > 0) { switch (kind) { case "yzgzp": strNumber = "07" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2); break; case "ezgzp": strNumber = "08" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2); break; case "dzczp": strNumber = "BJ" + System.DateTime.Now.Year.ToString(); break; 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'); } ctrlNumber.Text = strNumber; if (currRecord != null) currRecord.OrgName = str; //ContentChanged(ctrlNumber); } } LockExcel(); }
new public string ToString() { return(StringHelper.ConvertAweString(awe_jsvalue_to_string(instance))); }
public void Bind(IEnumerable <IEntityPropertyMapping> properties, Table table, IDictionary <string, MetaAttribute> inheritedMetas, Action <Property> modifier, Action <Property> addToModelAction) { if (table == null) { throw new ArgumentNullException("table"); } if (modifier == null) { throw new ArgumentNullException("modifier"); } if (addToModelAction == null) { throw new ArgumentNullException("addToModelAction"); } foreach (var entityPropertyMapping in properties) { Property property = null; string propertyName = entityPropertyMapping.Name; ICollectionPropertiesMapping collectionMapping; HbmManyToOne manyToOneMapping; HbmAny anyMapping; HbmOneToOne oneToOneMapping; HbmProperty propertyMapping; HbmComponent componentMapping; HbmDynamicComponent dynamicComponentMapping; HbmNestedCompositeElement nestedCompositeElementMapping; HbmKeyProperty keyPropertyMapping; HbmKeyManyToOne keyManyToOneMapping; HbmProperties propertiesMapping; if ((propertyMapping = entityPropertyMapping as HbmProperty) != null) { var value = new SimpleValue(table); new ValuePropertyBinder(value, Mappings).BindSimpleValue(propertyMapping, propertyName, true); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); BindValueProperty(propertyMapping, property); } else if ((collectionMapping = entityPropertyMapping as ICollectionPropertiesMapping) != null) { var collectionBinder = new CollectionBinder(Mappings); string propertyPath = propertyName == null ? null : StringHelper.Qualify(propertyBasePath, propertyName); Mapping.Collection collection = collectionBinder.Create(collectionMapping, entityName, propertyPath, persistentClass, mappedClass, inheritedMetas); mappings.AddCollection(collection); property = CreateProperty(collectionMapping, className, collection, inheritedMetas); BindCollectionProperty(collectionMapping, property); } else if ((propertiesMapping = entityPropertyMapping as HbmProperties) != null) { var subpath = propertyName == null ? null : StringHelper.Qualify(propertyBasePath, propertyName); var value = CreateNewComponent(table); BindComponent(propertiesMapping, value, null, entityName, subpath, componetDefaultNullable, inheritedMetas); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); BindComponentProperty(propertiesMapping, property, value); } else if ((manyToOneMapping = entityPropertyMapping as HbmManyToOne) != null) { var value = new ManyToOne(table); BindManyToOne(manyToOneMapping, value, propertyName, true); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); BindManyToOneProperty(manyToOneMapping, property); } else if ((componentMapping = entityPropertyMapping as HbmComponent) != null) { string subpath = propertyName == null ? null : StringHelper.Qualify(propertyBasePath, propertyName); var value = CreateNewComponent(table); // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute System.Type reflectedClass = mappedClass == null ? null : GetPropertyType(componentMapping.Class, mappedClass, propertyName, componentMapping.Access); BindComponent(componentMapping, value, reflectedClass, entityName, subpath, componetDefaultNullable, inheritedMetas); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); BindComponentProperty(componentMapping, property, value); } else if ((oneToOneMapping = entityPropertyMapping as HbmOneToOne) != null) { var value = new OneToOne(table, persistentClass); BindOneToOne(oneToOneMapping, value); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); BindOneToOneProperty(oneToOneMapping, property); } else if ((dynamicComponentMapping = entityPropertyMapping as HbmDynamicComponent) != null) { string subpath = propertyName == null ? null : StringHelper.Qualify(propertyBasePath, propertyName); var value = CreateNewComponent(table); // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute System.Type reflectedClass = mappedClass == null ? null : GetPropertyType(dynamicComponentMapping.Class, mappedClass, propertyName, dynamicComponentMapping.Access); BindComponent(dynamicComponentMapping, value, reflectedClass, entityName, subpath, componetDefaultNullable, inheritedMetas); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); BindComponentProperty(dynamicComponentMapping, property, value); } else if ((anyMapping = entityPropertyMapping as HbmAny) != null) { var value = new Any(table); BindAny(anyMapping, value, true); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); BindAnyProperty(anyMapping, property); } else if ((nestedCompositeElementMapping = entityPropertyMapping as HbmNestedCompositeElement) != null) { if (component == null) { throw new AssertionFailure("Nested Composite Element without a owner component."); } string subpath = propertyName == null ? null : StringHelper.Qualify(propertyBasePath, propertyName); var value = CreateNewComponent(table); // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute System.Type reflectedClass = mappedClass == null ? null : GetPropertyType(nestedCompositeElementMapping.Class, mappedClass, propertyName, nestedCompositeElementMapping.access); BindComponent(nestedCompositeElementMapping, value, reflectedClass, entityName, subpath, componetDefaultNullable, inheritedMetas); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); } else if ((keyPropertyMapping = entityPropertyMapping as HbmKeyProperty) != null) { var value = new SimpleValue(table); new ValuePropertyBinder(value, Mappings).BindSimpleValue(keyPropertyMapping, propertyName, componetDefaultNullable); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); } else if ((keyManyToOneMapping = entityPropertyMapping as HbmKeyManyToOne) != null) { var value = new ManyToOne(table); BindKeyManyToOne(keyManyToOneMapping, value, propertyName, componetDefaultNullable); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); } if (property != null) { modifier(property); property.LogMapped(log); addToModelAction(property); } } }
void ctrl_Leave(object sender, EventArgs e) { LP_Temple lp = (LP_Temple)(sender as Control).Tag; string str = (sender as Control).Text; if (dsoFramerWordControl1==null||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; } if (currRecord!=null) currRecord.OrgName = str; //ContentChanged(ctrlNumber); } } LockExcel(wb, xx); }
public static SqlDbType GetSQLDataType(string sqlTypeString) { if (StringHelper.Match(sqlTypeString, "BigInt", true)) { return(SqlDbType.BigInt); } else if (StringHelper.Match(sqlTypeString, "Binary", true)) { return(SqlDbType.Binary); } else if (StringHelper.Match(sqlTypeString, "Bit", true)) { return(SqlDbType.Bit); } else if (StringHelper.Match(sqlTypeString, "Char", true)) { return(SqlDbType.Char); } else if (StringHelper.Match(sqlTypeString, "DateTime", true)) { return(SqlDbType.DateTime); } else if (StringHelper.Match(sqlTypeString, "Decimal", true)) { return(SqlDbType.Decimal); } else if (StringHelper.Match(sqlTypeString, "Numeric", true)) { return(SqlDbType.Decimal); } else if (StringHelper.Match(sqlTypeString, "Float", true)) { return(SqlDbType.Float); } else if (StringHelper.Match(sqlTypeString, "Image", true)) { return(SqlDbType.Image); } else if (StringHelper.Match(sqlTypeString, "Int", true)) { return(SqlDbType.Int); } else if (StringHelper.Match(sqlTypeString, "Money", true)) { return(SqlDbType.Money); } else if (StringHelper.Match(sqlTypeString, "NChar", true)) { return(SqlDbType.NChar); } else if (StringHelper.Match(sqlTypeString, "NText", true)) { return(SqlDbType.NText); } else if (StringHelper.Match(sqlTypeString, "NVarChar", true)) { return(SqlDbType.NVarChar); } else if (StringHelper.Match(sqlTypeString, "Real", true)) { return(SqlDbType.Real); } else if (StringHelper.Match(sqlTypeString, "UniqueIdentifier", true)) { return(SqlDbType.UniqueIdentifier); } else if (StringHelper.Match(sqlTypeString, "SmallDateTime", true)) { return(SqlDbType.SmallDateTime); } else if (StringHelper.Match(sqlTypeString, "SmallInt", true)) { return(SqlDbType.SmallInt); } else if (StringHelper.Match(sqlTypeString, "SmallMoney", true)) { return(SqlDbType.SmallMoney); } else if (StringHelper.Match(sqlTypeString, "Text", true)) { return(SqlDbType.Text); } else if (StringHelper.Match(sqlTypeString, "Timestamp", true)) { return(SqlDbType.Timestamp); } else if (StringHelper.Match(sqlTypeString, "RowVersion", true)) { return(SqlDbType.Timestamp); } else if (StringHelper.Match(sqlTypeString, "TinyInt", true)) { return(SqlDbType.TinyInt); } else if (StringHelper.Match(sqlTypeString, "VarBinary", true)) { return(SqlDbType.VarBinary); } else if (StringHelper.Match(sqlTypeString, "VarChar", true)) { return(SqlDbType.VarChar); } else if (StringHelper.Match(sqlTypeString, "Variant", true)) { return(SqlDbType.Variant); } else if (StringHelper.Match(sqlTypeString, "Xml", true)) { return(SqlDbType.Xml); } else if (StringHelper.Match(sqlTypeString, "Udt", true)) { return(SqlDbType.Udt); } else if (StringHelper.Match(sqlTypeString, "Structured", true)) { return(SqlDbType.Structured); } else if (StringHelper.Match(sqlTypeString, "Date", true)) { return(SqlDbType.Date); } else if (StringHelper.Match(sqlTypeString, "Time", true)) { return(SqlDbType.Time); } else if (StringHelper.Match(sqlTypeString, "DateTime2", true)) { return(SqlDbType.DateTime2); } else if (StringHelper.Match(sqlTypeString, "DateTimeOffset", true)) { return(SqlDbType.DateTimeOffset); } else if (StringHelper.Match(sqlTypeString, "sysname", true)) { return(SqlDbType.NVarChar); } else { throw new Exception("Unknown SQL data type!"); } }
/// <summary> /// Opens a text file, reads content without BOM /// </summary> /// <param name="path">The file to open for reading.</param> /// <returns>A string containing all lines of the file.</returns> public static async Task <string> ReadFileWithoutBomAsync(string path) { var content = await ReadAllBytesAsync(path); return(StringHelper.ConvertFromBytesWithoutBom(content)); }
public override System.String ToString() { return (string.Format("{0}({1}{2}) as {3}", GetType().FullName, Table.Name, StringHelper.CollectionToString((ICollection)Columns), name)); }
/// <summary> /// 图文回复 /// </summary> /// <param name="user"></param> /// <param name="entity"></param> /// <param name="keywords"></param> /// <param name="imgmsg"></param> /// <returns></returns> public IActionResult ImgTextReplyForm(SysUser user, ImgTextReply entity = null, string[] keywords = null, string imgmsg = null) { if (Request.IsAjaxRequest()) { StateCode state = ServiceIoc.Get <ImgTextReplyService>().Save(user, entity, keywords, imgmsg); return(Json(GetResult(state))); } else { //上传票据ID ViewBag.Ticket = StringHelper.GetEncryption(ImgType.ImgTextReply_Title + "#" + bid.ToString()); //上传票据ID ViewBag.DetailsTicket = StringHelper.GetEncryption(ImgType.ImgTextReply_Details + "#" + bid.ToString()); //缺省图片路径 ViewBag.defimgurl = ResXmlConfig.Instance.DefaultImgSrc(AppGlobal.Res, ImgType.ImgTextReply_Title); //用户图片路径 ViewBag.imgurl = string.Empty; //缺省图片路劲 ViewBag.defurl = ResXmlConfig.Instance.DefaultImgSrc(AppGlobal.Res, ImgType.ImgTextReply_Title); ViewBag.imgurl = ViewBag.defimgurl; //地图坐标 ViewBag.lat_lng = "22.541234,114.06262"; ViewBag.address_text = "广东省深圳市福田区益田路48号"; /**********回复外链类型************/ Dictionary <int, string> imgTextTypes = new Dictionary <int, string>(); imgTextTypes.Add(MsgContentType.ImgTextDetails, "请选择"); foreach (var v in MsgContentType.typeList) { imgTextTypes.Add(v.Key, v.Value); } ViewBag.imgTextTypes = imgTextTypes; entity = ServiceIoc.Get <ImgTextReplyService>().GetById(bid); if (entity != null) { Img img = ServiceIoc.Get <ImgService>().GetImg(ImgType.ImgTextReply_Title, entity.id); if (img != null) { ViewBag.imgurl = img.getImgUrl(); } ViewBag.keywords = ServiceIoc.Get <KeyWordService>().GetKeywords(bid, KeyWordBizType.ImgTextReply); ViewBag.entity = JsonConvert.SerializeObject(entity); long[] moreIds = StringHelper.StringToLongArray(entity.quote_detailsIds); //绑定多图文 ViewBag.moreImgTextReplys = ServiceIoc.Get <ImgTextReplyService>().GetTextReplysByIds(moreIds); long[] recIds = StringHelper.StringToLongArray(entity.rec_detailsIds); //绑定推荐阅读 ViewBag.recImgTextReplys = ServiceIoc.Get <ImgTextReplyService>().GetTextReplysByIds(recIds); switch (entity.content_type) { //外链 case MsgContentType.OutLink: ViewBag.outlink = entity.content_value; break; //导航 case MsgContentType.Navigation: if (!string.IsNullOrEmpty(entity.content_value) && entity.content_value.IndexOf(",") != -1 && entity.content_value.IndexOf("#") != -1) { string val = entity.content_value.Split('#')[0].ToString(); if (val.Length > 3) { ViewBag.lat_lng = val; } ViewBag.address_text = entity.content_value.Split('#')[1].ToString(); } break; } } if (ViewBag.moreImgTextReplys == null) { ViewBag.moreImgTextReplys = new List <ImgTextReply>(); } if (ViewBag.recImgTextReplys == null) { ViewBag.recImgTextReplys = new List <ImgTextReply>(); } } return(View()); }
/// <summary> /// 公众号设置 /// </summary> /// <param name="user"></param> /// <param name="auth_code"></param> /// <param name="expires_in"></param> /// <returns></returns> public IActionResult AccountSetting(SysUser user, string auth_code = "", string expires_in = "") { //当前用户加密ID ViewBag.Ticket = StringHelper.GetEncryption(bid.ToString()); //用户图片路径 ViewBag.imgurl = string.Empty; ViewBag.OpenToken = ""; ViewBag.AscKey = ""; //缺省图片路劲 ViewBag.defimgurl = ResXmlConfig.Instance.DefaultImgSrc(AppGlobal.Res, ImgType.WX_Account); ViewBag.wx_account_imgurl = ViewBag.defimgurl; WeChatAccount account = ServiceIoc.Get <WeChatAccountService>().Get(); if (account != null) { Img img = ServiceIoc.Get <ImgService>().GetImg(ImgType.WX_Account, account.id); if (img != null) { ViewBag.wx_account_imgurl = string.IsNullOrEmpty(img.getImgUrl()) ? ViewBag.defimgurl : img.getImgUrl(); } ViewBag.account = JsonConvert.SerializeObject(account); } else { ViewBag.Token = StringHelper.CreateRandomCode(10); } WeChatMerchant merchant = ServiceIoc.Get <WeChatMerchantService>().Get(); if (merchant != null) { ViewBag.merchant = JsonConvert.SerializeObject(merchant); } WXOpenAccount openAcount = ServiceIoc.Get <WXOpenAccountService>().Get(); if (openAcount != null) { ViewBag.openAcount = JsonConvert.SerializeObject(openAcount); } WXOpenSetting openSetting = ServiceIoc.Get <WXOpenSettingService>().Get(); if (openSetting != null) { ViewBag.opensetting = JsonConvert.SerializeObject(openSetting); } else { ViewBag.OpenToken = StringHelper.GetRandomCode(10); ViewBag.AscKey = StringHelper.GetRandomCode(43); } ViewBag.AuthTitle = "待微信推送票据"; ViewBag.url = "javascript:;"; //获取当前凭据 WXOpenCmptVerifyTicket ticket = ServiceIoc.Get <WXOpenAuthService>().GetCmptVerifyTicket(); if (ticket != null && ConfigManage.AppSettings <bool>("WeChatSettings:IsOpenAuthUrl")) { if (ticket.ComponentVerifyTicket != null) { ViewBag.WXOpenTicket = ticket.ComponentVerifyTicket.Value; string cmpt_access_token = ServiceIoc.Get <WXOpenAuthService>().GetCmptAccessToken(openSetting, ViewBag.WXOpenTicket); string pre_auth_code = ServiceIoc.Get <WXOpenAuthService>().GetOpenPreAuthCode(cmpt_access_token, openSetting.component_appid); string redirect_uri = AppGlobal.Admin + "WeChat/AccountSetting"; ViewBag.AuthTitle = "授权公众号"; //授权地址 ViewBag.url = WeChatOpenHelper.GetOpenOuthUrl(openSetting.component_appid, pre_auth_code, redirect_uri); } } //授权回调 if (!string.IsNullOrEmpty(auth_code) && !string.IsNullOrEmpty(expires_in)) { //组件Token string cmpt_access_token = ServiceIoc.Get <WXOpenAuthService>().GetCmptAccessToken(openSetting, ticket.ComponentVerifyTicket.Value); //使用授权码换取公众号的接口调用凭据和授权信息 WXOpenAuthFun auth_fun = ServiceIoc.Get <WXOpenAuthService>().GetAuthInfo(cmpt_access_token, openSetting.component_appid, auth_code); //组件ID string cmpt_token = ServiceIoc.Get <WXOpenAuthService>().GetCmptAccessToken(openSetting, ticket.ComponentVerifyTicket.Value); //成功 if (auth_fun != null && !string.IsNullOrEmpty(cmpt_token)) { ServiceIoc.Get <WXOpenAccountService>().AuthWeChatAccount(user.id, cmpt_token, openSetting.component_appid, auth_fun.authorization_info.authorizer_appid); } return(Redirect(AppGlobal.Admin + "WeChat/AccountSetting")); } return(View()); }
public string[] GetContent(List<int> wcount) { StringHelper sh = new StringHelper(); string[] colArr = new string[m_ColName.Length]; string[] useforadd = new string[m_ColName.Length]; int[] rows = new int[m_ColName.Length]; int max = 1; DataTable dt=GetDS(); for (int j = 0; j < dt.Rows.Count; j++) { max = 1; for (int i = 0; i < dt.Columns.Count; i++) { string oneCol = dt.Rows[j][i].ToString(); string splitRst = sh.GetPlitStringN(oneCol, wcount[i]); if (GetPlitLen(splitRst) > max) max = GetPlitLen(splitRst); colArr[i] += splitRst; useforadd[i] = splitRst; if (i == dt.Columns.Count - 1 && max != 1) { AddMauRow(ref colArr,useforadd, max); } } } RomoveEnd(ref colArr); return colArr; }
protected void btnOK_Click(object sender, EventArgs e) { if (ViewState["txtUSER_NAME"] == null || ViewState["txtUSER_NAME"].ToString() != txtUSER_NAME.Value) { SYS_USER hadCond = new SYS_USER(); hadCond.USER_NAME = txtUSER_NAME.Value; if (BLLTable<SYS_USER>.Exists(hadCond)) { litWarn.Text = "此用户已经存在,请重新输入!或换个名称。"; return; } } try { SYS_USER valObj = new SYS_USER(); if (txtUSER_ID.Value != "") valObj.USER_ID = Convert.ToDecimal(txtUSER_ID.Value); if (txtUSER_NAME.Value != "") valObj.USER_NAME = Convert.ToString(txtUSER_NAME.Value); if (txtPASS.Value != "") valObj.PASS =StringHelperExd.StringToMD5(txtPASS.Value); if (txtEMAIL.Value != "") valObj.EMAIL = Convert.ToString(txtEMAIL.Value); if (txtLOGIN_IPS.Value != "") valObj.LOGIN_IPS = Convert.ToString(txtLOGIN_IPS.Value); #region wk(用户新增字段) //if (txtUSER_QQ.Value != "") valObj.USER_QQ = Convert.ToString(txtUSER_QQ.Value); if (txtUSER_Taobao.Value != "") valObj.USER_Taobao = Convert.ToString(txtUSER_Taobao.Value); if (txtIS_FeiQ_Remind.Checked != true) valObj.IS_FeiQ_Remind = Convert.ToBoolean(txtIS_FeiQ_Remind.Checked); if (txtIS_EMAIL_Remind.Checked != true) valObj.IS_EMAIL_Remind = Convert.ToBoolean(txtIS_EMAIL_Remind.Checked); if (txtIS_Taobao_Remind.Checked != true) valObj.IS_Taobao_Remind = Convert.ToBoolean(txtIS_Taobao_Remind.Checked); if (txtIS_QQ_Remind.Checked != true) valObj.IS_QQ_Remind = Convert.ToBoolean(txtIS_QQ_Remind.Checked); if (txtSTATE_FLAG.Value != "") valObj.USE_FLAG = Convert.ToString(txtSTATE_FLAG.Value); #endregion if (txtUSER_TYPE.Value != "") valObj.USER_TYPE = Convert.ToString(txtUSER_TYPE.Value); else valObj.USER_TYPE = "1"; valObj.STAFF_ID = wucSelStaff1.Staff_ID; valObj.REAL_NAME = wucSelStaff1.Staff_NAME; if (keyid != "") { valObj.EDITTIME = DateTime.Now; valObj.USER_ID = Convert.ToInt32(keyid); count = BLLTable<SYS_USER>.Factory(conn).Update(valObj, SYS_USER.Attribute.USER_ID); } else { valObj.EDITTIME = DateTime.Now; valObj.ADDTIME = DateTime.Now; count = BLLTable<SYS_USER>.Factory(conn).Insert(valObj, SYS_USER.Attribute.USER_ID); keyid = valObj.USER_ID.ToString(); } if (count > 0) { BLLTable<HR_STAFF>.Factory(conn).Update(HR_STAFF.Attribute.STAFF_ID, wucSelStaff1.Staff_ID, HR_STAFF.Attribute.USER_ID, keyid); BLLTable<SYS_USERROLE>.Factory(conn).Delete(SYS_USERROLE.Attribute.USER_ID, keyid);//先删除角色用户关联 string[] roles = StringHelper.GetStringArray(hidSelReals.Value, ',');//再根据当前选择的角色写入关联表 if (roles != null) { for (int i = 0; i < roles.Length; i++) { SYS_USERROLE ur = new SYS_USERROLE(); ur.ROLE_ID = int.Parse(roles[i]); ur.USER_ID = int.Parse(keyid); BLLTable<SYS_USERROLE>.Factory(conn).Insert(ur); } } StringBuilder sbData = new StringBuilder("({valObj:''"); List<AttributeItem> lstCol = valObj.af_AttributeItemList; for (int i = 0; i < lstCol.Count; i++) { object val = valObj.GetValue(lstCol[i]); if (val != null) { if (lstCol[i] == SYS_USER.Attribute.ADDTIME) { continue; } if (lstCol[i] == SYS_USER.Attribute.EDITTIME) { val = Convert.ToDateTime(val).ToString("yyyy-MM-dd"); } sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'"); } } sbData.Append("})"); Button btn = (Button)sender; if (btn.ID == "btnOK") { if (ViewState["hadSave"] == null) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true); } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true); } } else { txtUSER_NAME.Value = ""; txtPASS.Value = ""; txtEMAIL.Value = ""; txtLOGIN_IPS.Value = ""; txtSTATE_FLAG.Value = ""; txtUSER_TYPE.Value = ""; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "parent.addNewToList(\"" + sbData.ToString() + "\");", true); ViewState["hadSave"] = 1; } } } catch (Exception ex) { litWarn.Text = ex.Message; } }
public void FillMutilRows(ExcelAccess ea, int i, LP_Temple lp, string str, List<int> arrCellCount, string[] arrCellPos) { StringHelper help = new StringHelper(); string[] extraWord = lp.ExtraWord.Split(pchar); if (lp.CtrlType.IndexOf("uc_gridcontrol") > -1) { str = help.GetPlitString(str, arrCellCount[1]); string[] arrRst = str.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); int j = 0; for (; i < arrCellPos.Length; i++) { if (j >= arrRst.Length) break; try { if (lp.isExplorer != 1) ea.SetCellValue(arrRst[j], GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]); } catch { } 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++; } } else { string strarrRst = str; int i1 = strarrRst.IndexOf("\r\n"); for (; i < arrCellPos.Length; i++) { i1 = strarrRst.IndexOf("\r\n"); if (i1 > help.GetFristLen(strarrRst, arrCellCount[i])) i1 = help.GetFristLen(strarrRst, arrCellCount[i]); if (i1 == 0) { strarrRst = strarrRst.Substring(2); i1 = strarrRst.IndexOf("\r\n"); if (i1 > help.GetFristLen(strarrRst, arrCellCount[i])) i1 = help.GetFristLen(strarrRst, arrCellCount[i]); } if (i1 == -1) i1 = help.GetFristLen(str, arrCellCount[i]); if (strarrRst.Length > i1 + 1 && (strarrRst.Substring(i1, 1) == "," || strarrRst.Substring(i1, 1) == "。" || strarrRst.Substring(i1 + 1, 1) == "、" || strarrRst.Substring(i1 + 1, 1) == ":" || strarrRst.Substring(i1 + 1, 1) == "!")) { i1 = i1 + 1; } //if (strarrRst.Length <= help.GetFristLen(str, arrCellCount[i])) //{ // try // { // if (lp.isExplorer != 1) ea.SetCellValue(strarrRst, GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]); // } // catch { } // if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i])) // { // WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue; // tfv.ControlValue = strarrRst; // 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 = strarrRst; // 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); // } // break; //} //else { if (strarrRst.Length >= i1) { try { if (lp.isExplorer != 1) if (lp.isExplorer != 1) ea.SetCellValue(strarrRst.Substring(0, i1), GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]); } catch { } if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i])) { WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue; tfv.ControlValue = strarrRst.Substring(0, i1); 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 = strarrRst.Substring(0, i1); 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); } strarrRst = strarrRst.Substring(i1); } else { try { if (lp.isExplorer != 1) if (lp.isExplorer != 1) ea.SetCellValue(strarrRst, GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]); } catch { } if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i])) { WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue; tfv.ControlValue = strarrRst; 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 = strarrRst; 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); } strarrRst = ""; } //i++; //strarrRst = help.GetPlitString(strarrRst, arrCellCount[i]); } } } }
public void SetName(string name) { Name = StringHelper.IsNullOrEmptyOrWhiteSpace(name) ? throw new ArgumentNullException(nameof(name)) : name; }
/// <summary> /// The main method that handles all filtering. Every change on the filter panel causes this event to fire. /// It is important to manage the fact that this method may be called recursively and so nesting can be tricky! /// </summary> /// <param name="AFilterString">On entry this parameter contains the filter control's best guess for the current filter. /// The code can modify this string in the light of current control values.</param> public void ApplyFilterManual(ref string AFilterString) { if ((FCurrentLedgerYear < 0) || (FCurrentLedgerPeriod < 0)) { return; } string WorkingFilter = String.Empty; string AdditionalFilter = String.Empty; bool ShowingAllPeriods = false; // Remove the old base filter if (FPrevBaseFilter.Length > 0) { AdditionalFilter = AFilterString.Substring(FPrevBaseFilter.Length); if (AdditionalFilter.StartsWith(CommonJoinString.JOIN_STRING_SQL_AND)) { AdditionalFilter = AdditionalFilter.Substring(CommonJoinString.JOIN_STRING_SQL_AND.Length); } } int NewYear = FcmbYearEnding.GetSelectedInt32(); if (NewYear != FPrevYearEnding) { FPrevYearEnding = NewYear; //TLogging.Log(String.Format("RefreshPeriods for Year {0}", newYear)); RefreshPeriods(NewYear); // Apply the last good filter as we unwind the nesting AFilterString = FPrevFilter; return; } int NewPeriod = FcmbPeriod.GetSelectedInt32(); if (NewYear == -1) { NewYear = FCurrentLedgerYear; WorkingFilter = String.Format("{0}={1}", ABatchTable.GetBatchYearDBName(), NewYear); ShowingAllPeriods = true; } else { WorkingFilter = String.Format( "{0}={1}", ABatchTable.GetBatchYearDBName(), NewYear); if (NewPeriod == 0) //All periods for year { //Nothing to add to filter ShowingAllPeriods = true; } else if (NewPeriod == -1) { WorkingFilter += String.Format(" AND {0} >= {1}", ABatchTable.GetBatchPeriodDBName(), FCurrentLedgerPeriod); } else if (NewPeriod > 0) { WorkingFilter += String.Format(" AND {0}={1}", ABatchTable.GetBatchPeriodDBName(), NewPeriod); } } if (!BatchYearIsLoaded(NewYear)) { FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadABatch(FLedgerNumber, NewYear, NewPeriod)); // Set the flag on the transaction tab to show the status dialog again when the transactions are loaded for a new year TFrmGLBatch glBatchForm = (TFrmGLBatch)FPetraUtilsObject.GetForm(); glBatchForm.GetTransactionsControl().ShowStatusDialogOnLoad = true; } if (FrbtEditing.Checked) { StringHelper.JoinAndAppend(ref WorkingFilter, String.Format("{0}='{1}'", ABatchTable.GetBatchStatusDBName(), MFinanceConstants.BATCH_UNPOSTED), CommonJoinString.JOIN_STRING_SQL_AND); } else if (FrbtPosting.Checked) { StringHelper.JoinAndAppend(ref WorkingFilter, String.Format("({0}='{1}') AND ({2}={3}) AND ({2}<>0) AND (({4}=0) OR ({4}={2}))", ABatchTable.GetBatchStatusDBName(), MFinanceConstants.BATCH_UNPOSTED, ABatchTable.GetBatchCreditTotalDBName(), ABatchTable.GetBatchDebitTotalDBName(), ABatchTable.GetBatchControlTotalDBName()), CommonJoinString.JOIN_STRING_SQL_AND); } else //(FrbtAll.Checked) { } FFilterFindPanelObject.FilterPanelControls.SetBaseFilter(WorkingFilter, FrbtAll.Checked && ShowingAllPeriods); FPrevBaseFilter = WorkingFilter; AFilterString = WorkingFilter; StringHelper.JoinAndAppend(ref AFilterString, AdditionalFilter, CommonJoinString.JOIN_STRING_SQL_AND); FPrevFilter = AFilterString; }
protected override AcceptStatus Accept(BytesRef term) { return(StringHelper.StartsWith(term, prefix) ? AcceptStatus.YES : AcceptStatus.NO); }
public void Process(IUnitOfWork db, EmailReadingResult result) { if (result.Status == EmailMatchingResultStatus.New && result.HasMatches) { var subject = result.Email.Subject ?? ""; if (EmailHelper.IsAutoCommunicationAddress(result.Email.From) && subject.StartsWith("Your e-mail to")) { return; //NOTE: Skip processing our emails to customer } _log.Info("AddCommentEmailRule, WasEmailProcessed=" + result.WasEmailProcessed); if (!result.WasEmailProcessed) { //var orderNumber = result.MatchedIdList.FirstOrDefault(); var orders = db.Orders.GetAllByCustomerOrderNumbers(result.MatchedIdList); var message = " > " + EmailHelper.ExtractShortSubject(result.Email.Subject); message += " > " + EmailHelper.ExtractShortMessageBody(result.Email.Message, 200, true); var commentText = "Customers Email" + message; commentText = StringHelper.Substring(commentText, 110); if (orders.Any()) { foreach (var order in orders) { if ((order.OrderStatus == OrderStatusEnumEx.Unshipped || order.OrderStatus == OrderStatusEnumEx.Pending)) { db.OrderComments.Add(new OrderComment() { OrderId = order.Id, Message = commentText, Type = (int)CommentType.IncomingEmail, LinkedEmailId = result.Email.Id, CreateDate = _time.GetAppNowTime(), UpdateDate = _time.GetAppNowTime() }); OrderBatchDTO batch = null; if (order.BatchId.HasValue) { batch = db.OrderBatches.GetAsDto(order.BatchId.Value); } if (batch == null || !batch.IsLocked) //Exclude set onHold to orders in locked batch { order.OnHold = true; order.OnHoldUpdateDate = _time.GetAppNowTime(); } db.Commit(); _log.Info("Comment was added, orderId=" + order.AmazonIdentifier + ", customerOrderId=" + order.CustomerOrderId + ", comment=" + commentText); } } } else { _log.Info("No exist orders"); foreach (var orderNumber in result.MatchedIdList) { _log.Info("Action add comment was added, orderId=" + orderNumber); _actionService.AddAction(db, SystemActionType.AddComment, orderNumber, new AddCommentInput() { OrderNumber = orderNumber, Message = message, Type = (int)CommentType.IncomingEmail, LinkedEmailId = result.Email.Id, }, null, null); } } } } }
/* * CREATE a user on the DB */ public bool AddUser(string username, string password) { /* * I know we should be salting and hashing the password when saving, but for the simplicity of the exercise we'll skip that for now */ var cleanUsername = StringHelper.CleanInput(username); var cleanPassword = StringHelper.CleanInput(password); if (string.IsNullOrWhiteSpace(cleanUsername) || string.IsNullOrWhiteSpace(cleanPassword)) { throw new ArgumentException("The username and password fields cannot be empty."); } // check the list to see if the username already exists var usernameExists = Users.Exists(user => user.Username == cleanUsername); if (usernameExists) { Validation.RenderError($"Sorry the username {username} is already taken. Try a different username please."); return(false); } string account; bool acctExists; do { account = DataHelper.GenerateRandomString(10); // check in list to see if the generated account number already exists acctExists = Users.Exists(user => user.Account == account); } while (acctExists); var newUser = new User() { Account = account, Username = cleanUsername, Password = cleanPassword }; Users.Add(newUser); SerializeUsers(); return(true); /* * Database Solution * * int output; * var users = new List<User>(); * * using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(DbHelper.ConnectionValue("AltSourceTestDB"))) * { * // check in DB to see if the input username already exists * var foundUser = connection.Query<int>( * "dbo.SP_USERNAME_EXISTS @Username", * new { Username = username } * ).ToList()[0]; * * if (foundUser == 1) * { * Validation.RenderError($"Sorry the username {username} is already taken. Try a different username please."); * return false; * } * * int foundAcct; * string account; * * do * { * account = DataHelper.GenerateRandomString(10); * * // check in DB to see if the generated account number already exists * foundAcct = connection.Query<int>( * "dbo.SP_ACCOUNT_EXISTS @Account", * new { Account = account } * ).ToList()[0]; * } while (foundAcct == 1); * * users.Add(new User { Account = account, Username = username, Password = password }); * * output = connection.Execute( * "dbo.SP_ADD_USER @Account, @Username, @Password", * users); * } * * // should return rows affected * return output == 1; */ }
public bool HasProperty(string propertyName) { StringHelper propertyNameStr = new StringHelper(propertyName); return(awe_jsobject_has_property(instance, propertyNameStr.value())); }
/// <summary>添加记录</summary> /// <param name="param">实例<see cref="EntitySnapshotInfo"/>详细信息</param> public void Insert(EntitySnapshotInfo param) { this.ibatisMapper.Insert(StringHelper.ToProcedurePrefix(string.Format("{0}_Insert", tableName)), param); }
public JSValue(string value) { StringHelper valueStr = new StringHelper(value); instance = awe_jsvalue_create_string_value(valueStr.value()); }
/// <summary>修改记录</summary> /// <param name="param">实例<see cref="EntitySnapshotInfo"/>详细信息</param> public void Update(EntitySnapshotInfo param) { this.ibatisMapper.Update(StringHelper.ToProcedurePrefix(string.Format("{0}_Update", tableName)), param); }
/// <summary> /// Deserializes the object to the correct type. /// </summary> /// <param name="reader">The <see cref="JsonReader"/> to read from.</param> /// <param name="objectType">The interface type.</param> /// <param name="existingValue">The existing value of the object being read.</param> /// <param name="serializer">The <see cref="JsonSerializer"/> for deserialization.</param> /// <returns></returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } if (objectType == null) { throw new ArgumentNullException(nameof(objectType)); } if (serializer == null) { throw new ArgumentNullException(nameof(serializer)); } var jObject = JObject.Load(reader); var type = jObject.GetValue(CoreConstants.Serialization.ODataType); object instance; if (type != null) { var typeString = type.ToString(); typeString = typeString.Replace("#SP", "Graph.Community"); typeString = StringHelper.ConvertTypeToTitleCase(typeString); Type instanceType = null; if (TypeMappingCache.TryGetValue(typeString, out instanceType)) { instance = this.Create(instanceType); } else { var typeAssembly = objectType.GetTypeInfo().Assembly; instance = this.Create(typeString, typeAssembly); } // If @odata.type is set but we aren't able to create an instance of it use the method-provided // object type instead. This means unknown types will be deserialized as a parent type. if (instance == null) { instance = this.Create(objectType.AssemblyQualifiedName, /* typeAssembly */ null); } if (instance != null && instanceType == null) { // Cache the type mapping resolution if we haven't pulled it from the cache already. TypeMappingCache.TryAdd(typeString, instance.GetType()); } } else { instance = this.Create(objectType.AssemblyQualifiedName, /* typeAssembly */ null); } if (instance == null) { throw new ServiceException( new Error { Code = "generalException", Message = $"Unable to create an instance of type {objectType.AssemblyQualifiedName}.", }); } using (var objectReader = this.GetObjectReader(reader, jObject)) { serializer.Populate(objectReader, instance); return(instance); } }
// ------------------------------------------------------- // 查询 // ------------------------------------------------------- #region 函数:FindOne(string id) /// <summary>查询某条记录</summary> /// <param name="id">标识</param> /// <returns>返回实例<see cref="EntitySnapshotInfo"/>的详细信息</returns> public EntitySnapshotInfo FindOne(string id) { Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("Id", StringHelper.ToSafeSQL(id)); EntitySnapshotInfo param = this.ibatisMapper.QueryForObject <EntitySnapshotInfo>(StringHelper.ToProcedurePrefix(string.Format("{0}_FindOne", tableName)), args); return(param); }
/// <summary> /// 按照查询条件查询 /// </summary> /// <param name="query">查询条件</param> /// <param name="order">排序</param> /// <param name="currentPage">页号,-1不分页</param> /// <param name="pageSize">每页记录数</param> /// <param name="totalCount">总行数</param> /// <returns>集合</returns> public DataTable GetSurveyCategory(QuerySurveyCategory query, string order, int currentPage, int pageSize, out int totalCount) { string where = string.Empty; if (query.SelectType != Constant.INT_INVALID_VALUE) { //为1,则筛选登陆人管理的所属业务组的信息 if (query.SelectType == 1 && query.LoginID != Constant.INT_INVALID_VALUE) { where += " AND SurveyCategory.BGID IN ( Select BGID From UserGroupDataRigth gdr Where SurveyCategory.BGID=gdr.BGID AND UserID=" + query.LoginID + ")"; } } if (query.GroupName != Constant.STRING_INVALID_VALUE) { where += " AND BusinessGroup.NAME='" + StringHelper.SqlFilter(query.GroupName) + "'"; } if (query.Name != Constant.STRING_INVALID_VALUE) { where += " AND SurveyCategory.Name like '%" + StringHelper.SqlFilter(query.Name) + "%'"; } if (query.SCID != Constant.INT_INVALID_VALUE) { where += " AND SurveyCategory.SCID=" + query.SCID; } if (query.BGID.Value > 0) { where += " AND SurveyCategory.BGID=" + query.BGID; } if (query.Level != Constant.INT_INVALID_VALUE) { where += " AND SurveyCategory.Level=" + query.Level; } if (query.Pid != Constant.INT_INVALID_VALUE) { where += " AND SurveyCategory.Pid=" + query.Pid; } if (query.Status != Constant.INT_INVALID_VALUE) { where += " AND SurveyCategory.Status=" + query.Status; } if (query.TypeId != Constant.INT_INVALID_VALUE) { where += " AND SurveyCategory.TypeId=" + query.TypeId; } if (query.IsFilterStop) { where += " AND SurveyCategory.Status<>1"; } //add by qizq 2014-4-17 状态不等于某值,用于过滤等于-3(固定的分类)的 if (query.NoStatus != Constant.INT_INVALID_VALUE) { where += " AND SurveyCategory.Status<>" + query.NoStatus; } //add by anyy 默认分组和自定义分组 if (query.GroupStatus != Constant.STRING_EMPTY_VALUE) { where += " AND SurveyCategory.Status in " + query.GroupStatus; } if (query.Exclude == "ReturnVisit") { //排除客户回访的分类 where += " AND NOT (SurveyCategory.Name='客户回访' AND SurveyCategory.Status=-3)"; } DataSet ds; SqlParameter[] parameters = { new SqlParameter("@where", SqlDbType.NVarChar, 40000), new SqlParameter("@order", SqlDbType.NVarChar, 200), new SqlParameter("@pagesize", SqlDbType.Int, 4), new SqlParameter("@indexpage", SqlDbType.Int, 4), new SqlParameter("@totalRecorder", SqlDbType.Int, 4) }; parameters[0].Value = where; parameters[1].Value = order; parameters[2].Value = pageSize; parameters[3].Value = currentPage; parameters[4].Direction = ParameterDirection.Output; ds = SqlHelper.ExecuteDataset(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_SURVEYCATEGORY_SELECT, parameters); totalCount = (int)(parameters[4].Value); return(ds.Tables[0]); }
public void TestReverseWithSurrogatePairsExplicit() { var result = new StringHelper().Reverse("Les Mise\u0302rables"); Assert.AreEqual("selbare\u0302siM seL", result); }
public static List <LogInfo> DirCopy(EngineState s, CodeCommand cmd) { List <LogInfo> logs = new List <LogInfo>(); CodeInfo_DirCopy info = cmd.Info.Cast <CodeInfo_DirCopy>(); string srcDir = StringEscaper.Preprocess(s, info.SrcDir); string destDir = StringEscaper.Preprocess(s, info.DestDir); Debug.Assert(srcDir != null, $"{nameof(srcDir)} != null"); Debug.Assert(destDir != null, $"{nameof(destDir)} != null"); // Path Security Check if (!StringEscaper.PathSecurityCheck(destDir, out string errorMsg)) { return(LogInfo.LogErrorMessage(logs, errorMsg)); } // DestPath must be directory if (File.Exists(destDir)) { return(LogInfo.LogErrorMessage(logs, $"Cannot overwrite file [{destDir}] with directory [{srcDir}]")); } // Prepare progress report int progressCount = 0; object progressLock = new object(); IProgress <string> progress = new Progress <string>(f => { lock (progressLock) { progressCount += 1; double percent; if (NumberHelper.DoubleEquals(s.MainViewModel.BuildCommandProgressMax, 0)) { percent = 0; } else { percent = progressCount / s.MainViewModel.BuildCommandProgressMax * 100; } s.MainViewModel.BuildCommandProgressText = $"{f}\r\n({percent:0.0}%)"; s.MainViewModel.BuildCommandProgressValue = progressCount; } }); // Check if srcDir contains wildcard string wildcard = Path.GetFileName(srcDir); if (!StringHelper.IsWildcard(wildcard)) { // No Wildcard string destFullPath = Path.Combine(destDir, Path.GetFileName(srcDir)); if (Directory.Exists(destFullPath)) { logs.Add(new LogInfo(LogState.Overwrite, $"Directory [{destFullPath}] will be overwritten with [{srcDir}]")); } else { Directory.CreateDirectory(destFullPath); } // Get total file count int filesCount = FileHelper.GetFilesEx(srcDir, "*", SearchOption.AllDirectories).Length; // Copy directory s.MainViewModel.SetBuildCommandProgress("DirCopy Progress", filesCount); try { FileHelper.DirCopy(srcDir, destFullPath, new DirCopyOptions { CopySubDirs = true, Overwrite = true, Progress = progress, }); logs.Add(new LogInfo(LogState.Success, $"Directory [{srcDir}] copied to [{destFullPath}]", cmd)); } finally { s.MainViewModel.ResetBuildCommandProgress(); } } else { // With Wildcard if (Directory.Exists(destDir)) { logs.Add(new LogInfo(LogState.Overwrite, $"Directory [{destDir}] will be overwritten with [{srcDir}]")); } else { Directory.CreateDirectory(destDir); } string srcParentDir = Path.GetDirectoryName(srcDir); if (srcParentDir == null) { throw new InternalException("Internal Logic Error at DirCopy"); } DirectoryInfo dirInfo = new DirectoryInfo(srcParentDir); if (!dirInfo.Exists) { throw new DirectoryNotFoundException($"Source directory does not exist or cannot be found: {srcDir}"); } // Get total file count int filesCount = 0; FileInfo[] compatFiles = null; if (s.CompatDirCopyBug) { compatFiles = dirInfo.GetFiles(wildcard); filesCount += compatFiles.Length; } DirectoryInfo[] subDirs = dirInfo.GetDirectories(wildcard); foreach (DirectoryInfo d in subDirs) { string[] files = FileHelper.GetFilesEx(d.FullName, "*", SearchOption.AllDirectories); filesCount += files.Length; } // Copy directory s.MainViewModel.SetBuildCommandProgress("DirCopy Progress", filesCount); try { if (s.CompatDirCopyBug) { // Simulate WB082's [DirCopy,%SrcDir%\*,%DestDir%] FileCopy _bug_ Debug.Assert(compatFiles != null, $"Wrong {nameof(compatFiles)}"); foreach (FileInfo f in compatFiles) { progress.Report(f.FullName); File.Copy(f.FullName, Path.Combine(destDir, f.Name), true); } } // Copy first sub-level directory with wildcard // Note wildcard will not be applied to sub-directory copy foreach (DirectoryInfo d in subDirs) { FileHelper.DirCopy(d.FullName, Path.Combine(destDir, d.Name), new DirCopyOptions { CopySubDirs = true, Overwrite = true, Progress = progress, }); } } finally { s.MainViewModel.ResetBuildCommandProgress(); } logs.Add(new LogInfo(LogState.Success, $"Directory [{srcDir}] copied to [{destDir}]", cmd)); } return(logs); }
public HomeController() { _helper = new StringHelper(); }
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; try { if (lp.KindTable != activeSheetName) { if (lp.KindTable != "") { activeSheetName = lp.KindTable; try { sheet = wb.Application.Sheets[lp.KindTable] as Excel.Worksheet; } catch { sheet = wb.Application.Sheets[1] as Excel.Worksheet; } activeSheetIndex = sheet.Index; } else { sheet = wb.Application.Sheets[1] as Excel.Worksheet; activeSheetIndex = sheet.Index; activeSheetName = sheet.Name; } } if (lp.KindTable != "") { //try { // ea.ActiveSheet(lp.KindTable); //} catch { } } else { try { ea.ActiveSheet(1); } catch { } } if (lp.CellPos == "") { if (lp.CellName.IndexOf("简图") > -1) { unLockExcel(wb, sheet); PJ_tbsj tb = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '" + str + "'"); if (tb != null) { if (tb.picName != "表箱") { string tempPath = Path.GetTempPath(); string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb.S1; FileStream fs; fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); bw.Write(tb.picImage); bw.Flush(); bw.Close(); fs.Close(); //IDataObject data = new DataObject(DataFormats.FileDrop, new string[] { tempfile }); //MemoryStream memo = new MemoryStream(4); //byte[] bytes = new byte[] { (byte)(5), 0, 0, 0 }; //memo.Write(bytes, 0, bytes.Length); //data.SetData("ttt", memo); //Clipboard.SetDataObject(data); Image im = Bitmap.FromFile(tempfile); Bitmap bt = new Bitmap(im); DataObject dataObject = new DataObject(); dataObject.SetData(DataFormats.Bitmap, bt); Clipboard.SetDataObject(dataObject, true); } else { Microsoft.Office.Interop.Excel.Shape activShape = null; activShape = sheet.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, (float)153.75, (float)162.75, (float)22.5, (float)10.5); activShape.TextFrame.Characters(1, 1).Font.Size = 8; activShape.TextFrame.Characters(1, 1).Text = "1"; activShape.TextFrame.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; activShape.Cut(); } } } else { 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 = sheet.Name; valuehs.Add(lp.LPID, tfv); } } return; } unLockExcel(wb, sheet); string[] arrCellpos = lp.CellPos.Split(pchar); string[] arrtemp = lp.WordCount.Split(pchar); arrCellpos = StringHelper.ReplaceEmpty(arrCellpos).Split(pchar); if (lp.CtrlType.Contains("uc_gridcontrol") == false) { for (int i = 0; i < arrCellpos.Length; i++) { if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[i])) { valuehs.Remove(lp.LPID + "$" + arrCellpos[i]); } if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[i] + "完整时间")) { valuehs.Remove(lp.LPID + "$" + arrCellpos[i] + "完整时间"); } try { if (lp.isExplorer != 1) { //ea.SetCellValue("", GetCellPos(arrCellpos[i])[0], GetCellPos(arrCellpos[i])[1]); } } catch { } } } if (lp.CtrlType.Contains("uc_gridcontrol")) { FillTable(ea, lp, (sender as uc_gridcontrol).GetContent(String2Int(lp.WordCount.Split(pchar)))); LockExcel(wb, sheet); return; } else if (lp.CtrlType.Contains("DevExpress.XtraEditors.DateEdit")) { FillTime(ea, lp, (sender as DateEdit).DateTime); LockExcel(wb, sheet); return; } else if (lp.CtrlType.Contains("DevExpress.XtraEditors.SpinEdit")) { IList<string> strList = new List<string>(); if (arrCellpos.Length == 1 || string.IsNullOrEmpty(arrCellpos[1])) { try { if (lp.isExplorer != 1) ea.SetCellValue(str, GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]); } catch { } 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); } } else if (arrCellpos.Length > 1 && (!string.IsNullOrEmpty(arrCellpos[1]))) { int i = 0; try { if (lp.isExplorer != 1) ea.SetCellValue(str, GetCellPos(arrCellpos[i])[0], GetCellPos(arrCellpos[i])[1]); } catch { } if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[i])) { WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[i]] as WF_TableFieldValue; tfv.ControlValue = str; tfv.FieldId = lp.LPID; tfv.FieldName = lp.CellName; tfv.XExcelPos = GetCellPos(arrCellpos[i])[0]; tfv.YExcelPos = GetCellPos(arrCellpos[i])[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[i])[0]; tfv.YExcelPos = GetCellPos(arrCellpos[i])[1]; tfv.ExcelSheetName = sheet.Name; valuehs.Add(lp.LPID + "$" + arrCellpos[i], tfv); } } LockExcel(wb, sheet); return; } string[] extraWord = lp.ExtraWord.Split(pchar); List<int> arrCellCount = String2Int(arrtemp); string value = lp.ExtraWord; if (lp.ExtraWord == "合同编号") { for (int j = 0; j < arrCellpos.Length; j++) { if (str.Length > j) { string strNew = str.Substring(j, 1); try { if (lp.isExplorer != 1) ea.SetCellValue(strNew, GetCellPos(arrCellpos[j])[0], GetCellPos(arrCellpos[j])[1]); } catch { } if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0])) { WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue; tfv.ControlValue = strNew; 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 = strNew; 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); } } else break; } LockExcel(wb, sheet); return; } else if (lp.ExtraWord != "") { str = value.Replace("{0}", str); } if (lp.CellName == "工作班人员" || lp.CellName == "抢修班人员" || lp.CellName == "工作班成员") { LP_Temple lpt = MainHelper.PlatformSqlMap.GetOne<LP_Temple>(" where CellName='人数' and ParentID='" + parentTemple.LPID + "'"); Control relateCtrl = FindCtrl(lp.LPID); Control resCtrl = FindCtrl(lpt.LPID); if (relateCtrl != null) { string[] strcount = SelectorHelper.ToDBC(relateCtrl.Text).Split('、'); int irencount = 0; for (int iren = 0; iren < strcount.Length; iren++) { if (strcount[iren] != "") irencount++; } if (irencount != 0) { resCtrl.Text = irencount.ToString(); } } } if (arrCellpos.Length == 1 || string.IsNullOrEmpty(arrCellpos[1])) { try { if (lp.isExplorer != 1) { int[] cc = GetCellPos(arrCellpos[0]); ea.SetCellValue("'" + str, cc[0], cc[1]); } } catch { } 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 = sheet.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 = sheet.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(); string strNew = str; try { if (lp.isExplorer != 1) ea.SetCellValue("'" + strNew, GetCellPos(arrCellpos[j])[0], GetCellPos(arrCellpos[j])[1]); } catch { } 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 = sheet.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 = sheet.Name; valuehs.Add(lp.LPID + "$" + arrCellpos[j], tfv); } } } LockExcel(wb, sheet); return; } int i = 0; //if (arrCellCount.Count>1&&arrCellCount[0] != arrCellCount[1]) if (arrCellCount.Count > 1) { if ((lp.CtrlType.IndexOf("uc_gridcontrol") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[i])) || (lp.CtrlType.IndexOf("uc_gridcontrol") > -1 && str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[i]))) { try { if (lp.isExplorer != 1) ea.SetCellValue(str, GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]); } catch { } 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); } LockExcel(wb, sheet); return; } if (lp.CtrlType.IndexOf("uc_gridcontrol") > -1) { try { if (lp.isExplorer != 1) 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]); } catch { } 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]); } else { int i1 = str.IndexOf("\r\n"); if (i1 > help.GetFristLen(str, arrCellCount[0])) i1 = help.GetFristLen(str, arrCellCount[0]); if (i1 == -1) i1 = help.GetFristLen(str, arrCellCount[0]); if (str.Length > i1 + 1 && (str.Substring(i1, 1) == "," || str.Substring(i1, 1) == "。" || str.Substring(i1 + 1, 1) == "、" || str.Substring(i1 + 1, 1) == ":" || str.Substring(i1 + 1, 1) == "!")) { i1 = i1 + 1; } try { if (lp.isExplorer != 1) ea.SetCellValue(str.Substring(0, i1), GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]); } catch { } if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0])) { WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue; tfv.ControlValue = str.Substring(0, i1); 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, i1); 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(i1); 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 (parentTemple.CellName) { case "电力线路第一种工作票": case "yzgzp": //strNumber = "07" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2); if (bhht[str] != null) { strNumber = "07" + bhht[str].ToString(); } else strNumber = "07"; break; case "电力线路第二种工作票": case "ezgzp": //strNumber = "08" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2); 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(); strNumber = "06" + list[0].ToString().Substring(list[0].ToString().Length - 2, 2) + 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(); strNumber = list[0].ToString().Substring(list[0].ToString().Length - 2, 2) + System.DateTime.Now.Year.ToString(); break; case "低压线路第一种工作票": if (bhht[str] != null) { strNumber = "11" + bhht[str].ToString(); } else strNumber = "11"; break; case "低压线路第二种工作票": strNumber = "12" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2); break; default: strNumber = list[0].ToString().Substring(list[0].ToString().Length - 2, 2) + System.DateTime.Now.Year.ToString(); break; } //IList<LP_Record> listLPRecord = ClientHelper.PlatformSqlMap.GetList<LP_Record>("SelectLP_RecordList", " where kind = '" + kind + "' and number like '" + strNumber + "%'"); IList listLPRecord = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", string.Format("select ControlValue from WF_TableFieldValue where FieldName='编号' and UserControlId='{0}' and WorkFlowInsId!='" + WorkFlowData.Rows[0]["WorkFlowInsId"].ToString() + "' and ControlValue like '" + strNumber + "%' and id like '" + DateTime.Now.Year + "%' order by id desc", parentTemple.LPID)); if (kind == "yzgzp" || parentTemple.CellName == "电力线路第一种工作票") { //strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0') + "-1"; if (listLPRecord.Count == 0) strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0'); else { decimal udw = Convert.ToDecimal(listLPRecord[0]); strNumber = "0" + (udw + 1).ToString().PadLeft(3, '0'); } } else { int step = 1; if (ctrlNumber2 != null) step = 2; if (listLPRecord.Count == 0) strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0'); else { decimal udw = Convert.ToDecimal(listLPRecord[0].ToString().Substring(listLPRecord[0].ToString().Length - 3)); strNumber = listLPRecord[0].ToString().Substring(0, listLPRecord[0].ToString().Length - 3) + (udw + step).ToString().PadLeft(3, '0'); } if (ctrlNumber2 != null) { ctrlNumber2.Text = strNumber.Substring(0, strNumber.Length - 3) + (int.Parse(strNumber.Substring(strNumber.Length - 3)) + 1).ToString("000"); } //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, sheet); } catch { } }
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]); } }
/// <summary> /// Initializes a new instance of the <see cref="ListRadioStationsSteps"/> class. /// </summary> public ListRadioStationsSteps() { this.stringHelper = new StringHelper(); }
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++; } }
/// <summary>查询所有相关记录</summary> /// <param name="whereClause">SQL 查询条件</param> /// <param name="length">条数</param> /// <returns>返回所有实例<see cref="EntitySnapshotInfo"/>的详细信息</returns> public IList <EntitySnapshotInfo> FindAll(string whereClause, int length) { Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("WhereClause", StringHelper.ToSafeSQL(whereClause)); args.Add("Length", length); IList <EntitySnapshotInfo> list = this.ibatisMapper.QueryForList <EntitySnapshotInfo>(StringHelper.ToProcedurePrefix(string.Format("{0}_FindAll", tableName)), args); return(list); }
public HomeController(StringHelper helper) { _helper = helper; }
public string[] GetContent(List<int> wcount) { StringHelper sh = new StringHelper(); string[] colArr = new string[m_ColName.Length]; string[] useforadd = new string[m_ColName.Length]; int[] rows = new int[m_ColName.Length]; int max = 1; string newrow = ""; DataTable dt = GetDS(); for (int j = 0; j < dt.Rows.Count; j++) { max = 1; for (int i = 0; i < dt.Columns.Count; i++) { //DataRow dr= gridView1.GetDataRow(j); string oneCol = dt.Rows[j][i].ToString(); if (gridView1.Columns[i].ColumnEdit is RepositoryItemDateEdit && oneCol != "") { DevExpress.XtraEditors.DateEdit de = new DevExpress.XtraEditors.DateEdit(); de.DateTime = Convert.ToDateTime(oneCol); de.Properties.Mask.EditMask = gridView1.Columns[i].ColumnEdit.EditFormat.FormatString; de.Properties.Mask.UseMaskAsDisplayFormat = true; oneCol = de.Text; } else if (gridView1.Columns[i].ColumnEdit is RepositoryItemBaseSpinEdit && oneCol != "") { DevExpress.XtraEditors.SpinEdit de = new DevExpress.XtraEditors.SpinEdit(); de.Text = oneCol; de.Properties.EditMask = gridView1.Columns[i].ColumnEdit.DisplayFormat.FormatString; de.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; de.Properties.DisplayFormat.FormatString = gridView1.Columns[i].ColumnEdit.DisplayFormat.FormatString; oneCol = de.Text; } //if (oneCol != "") { //string splitRst = sh.GetPlitStringN(oneCol, wcount[i]); if (oneCol == "") oneCol = " "; string splitRst = oneCol; if (oneCol.Length > wcount[i]) splitRst = oneCol.Substring(0, wcount[i]); //if (GetPlitLen(splitRst) > max) // max = GetPlitLen(splitRst); colArr[i] += newrow + splitRst; useforadd[i] = newrow + splitRst; if (i == dt.Columns.Count - 1 && max != 1) { AddMauRow(ref colArr, useforadd, max); } } } newrow = "\r\n"; } RomoveEnd(ref colArr); Console.WriteLine("1"); return colArr; }
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) { 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); }
// ------------------------------------------------------- // 自定义功能 // ------------------------------------------------------- #region 函数:GetPaging(int startIndex, int pageSize, string whereClause, string orderBy, out int rowCount) /// <summary>分页函数</summary> /// <param name="startIndex">开始行索引数,由0开始统计</param> /// <param name="pageSize">页面大小</param> /// <param name="whereClause">WHERE 查询条件</param> /// <param name="orderBy">ORDER BY 排序条件</param> /// <param name="rowCount">行数</param> /// <returns>返回一个列表实例<see cref="EntitySnapshotInfo"/></returns> public IList <EntitySnapshotInfo> GetPaging(int startIndex, int pageSize, string whereClause, string orderBy, out int rowCount) { Dictionary <string, object> args = new Dictionary <string, object>(); orderBy = string.IsNullOrEmpty(orderBy) ? " ModifiedDate DESC " : orderBy; args.Add("StartIndex", startIndex); args.Add("PageSize", pageSize); args.Add("WhereClause", StringHelper.ToSafeSQL(whereClause)); args.Add("OrderBy", StringHelper.ToSafeSQL(orderBy)); args.Add("RowCount", 0); IList <EntitySnapshotInfo> list = this.ibatisMapper.QueryForList <EntitySnapshotInfo>(StringHelper.ToProcedurePrefix(string.Format("{0}_GetPaging", tableName)), args); rowCount = (int)this.ibatisMapper.QueryForObject(StringHelper.ToProcedurePrefix(string.Format("{0}_GetRowCount", tableName)), args); return(list); }
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]); j++; } }
protected Layer() { Id = StringHelper.GetRandomString(20); }
private static string Replace(string type, int size, int precision, int scale) { type = StringHelper.ReplaceOnce(type, LengthPlaceHolder, size.ToString()); type = StringHelper.ReplaceOnce(type, ScalePlaceHolder, scale.ToString()); return(StringHelper.ReplaceOnce(type, PrecisionPlaceHolder, precision.ToString())); }
void ctrl_Leave(object sender, EventArgs e) { LP_Temple lp = (LP_Temple)(sender as Control).Tag; string str = (sender as Control).Text; if (dsoFramerWordControl1 == null || dsoFramerWordControl1.MyExcel == null) { return; } try { //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) { 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 == "") { if (lp.CellName.IndexOf("绘图") > -1) { //unLockExcel(wb, xx); PJ_tbsj tb = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '" + str + "'"); if (tb != null) { if (tb.picName != "表箱") { string tempPath = Path.GetTempPath(); string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb.S1; FileStream fs; fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); bw.Write(tb.picImage); bw.Flush(); bw.Close(); fs.Close(); //IDataObject data = new DataObject(DataFormats.FileDrop, new string[] { tempfile }); //MemoryStream memo = new MemoryStream(4); //byte[] bytes = new byte[] { (byte)(5), 0, 0, 0 }; //memo.Write(bytes, 0, bytes.Length); //data.SetData("ttt", memo); //Clipboard.SetDataObject(data); Image im = Bitmap.FromFile(tempfile); Bitmap bt = new Bitmap(im); DataObject dataObject = new DataObject(); dataObject.SetData(DataFormats.Bitmap, bt); Clipboard.SetDataObject(dataObject, true); } else { Microsoft.Office.Interop.Excel.Shape activShape = null; activShape = xx.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, (float)153.75, (float)162.75, (float)22.5, (float)10.5); activShape.TextFrame.Characters(1, 1).Font.Size = 8; activShape.TextFrame.Characters(1, 1).Text = "1"; activShape.TextFrame.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; activShape.Cut(); } } } else { 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); string[] arrCellpos = lp.CellPos.Split(pchar); string[] arrtemp = lp.WordCount.Split(pchar); arrCellpos = StringHelper.ReplaceEmpty(arrCellpos).Split(pchar); 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; } else if (lp.CtrlType.Contains("DevExpress.XtraEditors.SpinEdit")) { IList<string> strList = new List<string>(); if (arrCellpos.Length == 1 || string.IsNullOrEmpty(arrCellpos[1])) { if (string.IsNullOrEmpty(str)) ea.SetCellValue("", GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]); else ea.SetCellValue("'" + str, GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[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); } } else if (arrCellpos.Length > 1 && (!string.IsNullOrEmpty(arrCellpos[1]))) { int i = 0; if (string.IsNullOrEmpty(str)) ea.SetCellValue("", GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]); else ea.SetCellValue("'" + str, 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 = str; tfv.FieldId = lp.LPID; tfv.FieldName = lp.CellName; tfv.XExcelPos = GetCellPos(arrCellpos[i])[0]; tfv.YExcelPos = GetCellPos(arrCellpos[i])[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[i])[0]; tfv.YExcelPos = GetCellPos(arrCellpos[i])[1]; tfv.ExcelSheetName = xx.Name; valuehs.Add(lp.LPID + "$" + arrCellpos[i], tfv); } } LockExcel(wb, xx); return; } string[] extraWord = lp.ExtraWord.Split(pchar); List<int> arrCellCount = String2Int(arrtemp); if (arrCellpos.Length == 1 || string.IsNullOrEmpty(arrCellpos[1])) { if (string.IsNullOrEmpty(str)) ea.SetCellValue("", GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]); else 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])) { if (string.IsNullOrEmpty(str)) ea.SetCellValue("", GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]); else 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; } if (currRecord != null) currRecord.OrgName = str; //ContentChanged(ctrlNumber); } } LockExcel(wb, xx); } catch { } }
private void TransferData() { this.szIcon = StringHelper.UTF8BytesToString(ref this.szIcon_ByteArray); this.szIcon_ByteArray = null; }
public void FillMutilRowsT(ExcelAccess ea, LP_Temple lp, string str, int cellcount, string arrCellPos, string coltemp) { StringHelper help = new StringHelper(); //str = help.GetPlitString(str, cellcount); string[] arrRst = str.Split(new string[] { "\r\n" }, StringSplitOptions.None); if (lp.ExtraWord == "横向") { for (int i = 0; i < arrRst.Length; i++) { ea.SetCellValue("'" + arrRst[i], GetCellPos(arrCellPos)[0], GetCellPos(arrCellPos)[1] + i); 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 + "-" + coltemp; tfv.XExcelPos = GetCellPos(arrCellPos)[0]; tfv.YExcelPos = GetCellPos(arrCellPos)[1] + i; tfv.ExcelSheetName = activeSheetName; } else { WF_TableFieldValue tfv = new WF_TableFieldValue(); tfv.ControlValue = arrRst[i]; tfv.FieldId = lp.LPID; tfv.FieldName = lp.CellName + "-" + coltemp; tfv.XExcelPos = GetCellPos(arrCellPos)[0]; tfv.YExcelPos = GetCellPos(arrCellPos)[1] + i; tfv.ExcelSheetName = activeSheetName; valuehs.Add(lp.LPID + "$" + Convert.ToString(GetCellPos(arrCellPos)[0] + i) + "|" + GetCellPos(arrCellPos)[1], tfv); } } } else { 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 + "-" + coltemp; 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 + "-" + coltemp; 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); } } } }
void ContentChanged(Control ctrl) { LP_Temple lp = (LP_Temple)ctrl.Tag; string str = ctrl.Text; if (dsoFramerWordControl1.MyExcel == null) { return; } unLockExcel(); Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook; ExcelAccess ea = new ExcelAccess(); ea.MyWorkBook = wb; ea.MyExcel = wb.Application; 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]); 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]); } } 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]); 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]); 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(); }