private int ExecuteCmdLet() { try { List <NavisionClientInformation> list = NavConnector.CheckRot(); if (list.Count > 0) { NavConnector navConnector = null; foreach (NavisionClientInformation navInfo in list) { if (navInfo.DatabaseName.Equals(DatabaseName, StringComparison.InvariantCultureIgnoreCase)) { navConnector = new NavConnector(navInfo); break; } } if (navConnector != null) { FileStream fs = new FileStream(FilePath, FileMode.Open); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, (int)fs.Length); fs.Close(); string fileContent = Encoding.GetEncoding(850).GetString(buffer); navConnector.SetObjectText(fileContent); return(0); } } } catch (Exception e) { } return(-1); }
protected override void ProcessRecord() { try { List <NavisionClientInformation> navisionClientInformationList = NavConnector.CheckRot(); NavConnector navConnector = null; if (navisionClientInformationList.Count == 0) { return; } foreach (NavisionClientInformation navInfo in navisionClientInformationList) { if (navInfo.DatabaseName.Equals(DatabaseName, StringComparison.InvariantCultureIgnoreCase)) { navConnector = new NavConnector(navInfo); break; } } if (navConnector != null) { Regex regex = new Regex(@"([^\\]*).*\s([0-9]*).txt"); int type, id; foreach (string o in SelectedObjectsList) { MatchCollection collection = regex.Matches(o); if (collection.Count > 0) { Match match = regex.Matches(o)[0]; type = (int)(NavObjectTypeClass.GetObjectTypeByString(match.Groups[1].Value)); int.TryParse(match.Groups[2].Value, out id); if (navConnector.CompileObject(type, id) != 0) { ErrorObjects.Add(o); } } } } } catch (Exception e) { WriteObject(e); return; } WriteObject(ErrorObjects); }
private int ExecuteCmdLet() { try { List <NavisionClientInformation> navisionClientInformationList = NavConnector.CheckRot(); if (navisionClientInformationList.Count > 0) { foreach (NavisionClientInformation navInfo in navisionClientInformationList) { if (navInfo.DatabaseName.Equals(DatabaseName, StringComparison.InvariantCultureIgnoreCase)) { return(0); } } } } catch { } return(-1); }
private int ExecuteCmdLet() { try { List <NavisionClientInformation> navisionClientInformationList = NavConnector.CheckRot(); NavConnector navConnector = null; if (navisionClientInformationList.Count == 0) { return(-1); } foreach (NavisionClientInformation navInfo in navisionClientInformationList) { if (navInfo.DatabaseName.Equals(DatabaseName, StringComparison.InvariantCultureIgnoreCase)) { navConnector = new NavConnector(navInfo); break; } } if (navConnector != null) { string path = Path.Combine(TempFolder, ObjectType.ToLower()); Directory.CreateDirectory(path); if (String.IsNullOrEmpty(ObjectFilter)) { throw new Exception("ObjectFilter null."); } string temp = navConnector.GetAllObjectText(NavObjectTypeClass.GetObjectTypeByString(ObjectType), GetObjectFilter()); path = Path.Combine(path, "Export.txt"); File.WriteAllText(path, temp); return(1); } return(-1); } catch (Exception e) { throw e; } }