private void Folder_Cut_A_Option_Click(object sender, RoutedEventArgs e) { Mode = ImportMode.UseAsArchive; Action = ImportAction.Cut; DialogResult = true; this.Close(); }
public static void ImportAll(string directoryName) { var namespaces = HelpLogic.AllTypes().Select(a => a.Namespace !).Distinct().ToDictionary(a => a); var types = HelpLogic.AllTypes().ToDictionary(a => a.FullName !); foreach (var path in Directory.GetFiles(directoryName, "*.help", SearchOption.AllDirectories)) { try { XDocument doc = XDocument.Load(path); ImportAction action = doc.Root !.Name == AppendixXml._Appendix ? AppendixXml.Load(doc): doc.Root !.Name == NamespaceXml._Namespace ? NamespaceXml.Load(doc, namespaces): doc.Root !.Name == EntityXml._Entity ? EntityXml.Load(doc, types): doc.Root !.Name == QueryXml._Query ? QueryXml.Load(doc) : throw new InvalidOperationException("Unknown Xml root: " + doc.Root.Name); ConsoleColor color = action == ImportAction.Inserted ? ConsoleColor.Green : action == ImportAction.Updated ? ConsoleColor.DarkGreen : action == ImportAction.Skipped ? ConsoleColor.Yellow : action == ImportAction.NoChanges ? ConsoleColor.DarkGray : throw new InvalidOperationException("Unexpected action"); SafeConsole.WriteLineColor(color, " {0} {1}".FormatWith(action, path)); } catch (Exception e) { SafeConsole.WriteLineColor(ConsoleColor.Red, " Error {0}:\r\n\t".FormatWith(path) + e.Message); } } }
public override void AppendCSS(Env env, Context context) { ImportAction action = GetImportAction(env.Parser.Importer); if (action == ImportAction.ImportNothing) { return; } if (action == ImportAction.ImportCss) { env.Output.Append(InnerContent); return; } env.Output.Append("@import ") .Append(OriginalPath.ToCSS(env)); if (Features) { env.Output .Append(" ") .Append(Features); } env.Output.Append(";"); if (!env.Compress) { env.Output.Append("\n"); } }
public void InternalizeAll(ImportAction action) { foreach (Document doc in Documents) { doc.Internalize(action); } }
private void Folder_Refer_VA_Option_Click(object sender, RoutedEventArgs e) { Mode = ImportMode.GenerateVirtualArchive; Action = ImportAction.Refer; DialogResult = true; this.Close(); }
private void Folder_Cut_C_Option_Click(object sender, RoutedEventArgs e) { Mode = ImportMode.NoClassification; Action = ImportAction.Cut; DialogResult = true; this.Close(); }
private void File_Refer_Option_Click(object sender, RoutedEventArgs e) { Action = ImportAction.Refer; Mode = ImportMode.NoClassification; DialogResult = true; this.Close(); }
static string GetActionName(MatchState state, ImportAction action) { switch (state) { case MatchState.Added: if (action == ImportAction.Ignore) { return("Don't Add"); } if (action == ImportAction.Update) { return("Update existing person"); } break; case MatchState.Deleted: if (action == ImportAction.Ignore) { return("Keep"); } break; case MatchState.Updated: if (action == ImportAction.Add) { return("Create new person"); } break; } return(action.ToString()); }
private void Folder_Clone_Clue_Option_Click(object sender, RoutedEventArgs e) { Mode = ImportMode.GenerateClues; Action = ImportAction.Clone; DialogResult = true; this.Close(); }
/// <summary> /// Add a single target to Home, return the document(s) generated during the process that are not classified (by a clue or VA). /// If no Exception generated then the operation succeeds. /// Documetns are returned immediately, but actual file operations happen in a seperate thread, a callback needs to be provided to get notification. /// </summary> /// Description (Stage 1): Load all documents specified by sources and return as soon as document object instances are generated - while actual file movement happens in the background /// Call FinishImport to do file operation and get a chance to notify user internal /*async Task<List<Document>>*/ List <Document> ImportTargets(string[] sources, ImportAction action, ImportMode mode, out int documentCount) { // Set up state bImportFinished = false; // A list of newly generated documents List <Document> virtualArchives = new List <Document>(); newlyImportedUnorganizedDocuments = new List <Document>(); lastImportAction = action; // Stage 1: Generate documents (Async) // Foreach source generate documents for it foreach (string path in sources) { switch (SystemHelper.IsFolder(path)) { // Handle as a folder case true: Document virtualArchive = null; newlyImportedUnorganizedDocuments.AddRange(ImportFolder(path, mode, out virtualArchive)); if (virtualArchive != null) { virtualArchives.Add(virtualArchive); } break; // Handle as a file case false: newlyImportedUnorganizedDocuments.Add(ImportFile(new FileInfo(path) /*, new DirectoryInfo(Path.GetDirectoryName(path))*/)); break; // Error case null: throw new InvalidOperationException("Path doesn't represent a file/folder."); } } // Return appropriately about current status documentCount = newlyImportedUnorganizedDocuments.Count; if (sources.Length == 1 && SystemHelper.IsFolder(sources[0]) == false) { return(newlyImportedUnorganizedDocuments); // If it's a single file, return the document } else // Depending on whether the documents are added in a classified manner { switch (mode) { case ImportMode.GenerateClues: newlyImportedUnorganizedDocuments.Clear(); // If it's classified, then return an empty list break; case ImportMode.GenerateVirtualArchive: return(virtualArchives); } } return(newlyImportedUnorganizedDocuments); }
public ImportDialog(Config config, ImportAction import) { this.config = config; this.import = import; SuspendLayout(); InitializeComponent(); ResumeLayout(false); }
public void SetPluginCommands( ImportAction import, ExportAction export) { ExportCommand = new AsyncCommand(token => ExportAsync(export, token)); ImportCommand = new AsyncCommand(token => ImportAsync(import, token)); OnPropertyChanged(nameof(ExportCommand)); OnPropertyChanged(nameof(ImportCommand)); }
public void Internalize(ImportAction action) { // Check for internalization if (_PhysicalLocationURI.IndexOf(HomeRootPathProtocol) != 0) // If we are not using an internal address { // Check to see if already in home, so we condense the path a bit if (action == ImportAction.Refer) { if (Path.IndexOf(Home.Location) == 0) { _PhysicalLocationURI = HomeRootPathProtocol + _PhysicalLocationURI.Substring(Home.Location.Length); } else { return; } } // Replace path else { string extension = System.IO.Path.GetExtension(Path); string relativePath; string newPath = GetLegalPhysicalLocation(out relativePath, extension); // Take appropriate file action using new path switch (action) { case ImportAction.Cut: FileHelper.MoveOrRenameDirectoryOrFile(Path, newPath); break; case ImportAction.Clone: if (Type == DocumentType.Archive) { ArchiveHelper.CopyDirectory(Path, newPath); } else { System.IO.File.Copy(Path, newPath); } break; case ImportAction.Refer: throw new InvalidOperationException("Should have been handled."); default: break; } // Change file path _PhysicalLocationURI = HomeRootPathProtocol + relativePath; // Notice original file's meta-name remains unchanged: meta names will tend to diverge from actual file name } } }
IAction ReadImportAction(XElement actionElement, ISyncConfiguration configuration, IPathResolver pathResolver) { var enabled = ReadActionEnabled(actionElement); var inputFilterName = ReadActionInputFilterName(actionElement); var syncFolder = ReadActionSyncFolder(actionElement); var action = new ImportAction(enabled, configuration, inputFilterName, syncFolder); ApplyCommonImportExportActionProperties(actionElement, action, configuration, pathResolver); return(action); }
private Import(string path, IImporter importer, Value features, bool isOnce) { if (path == null) throw new ParserException("Imports do not allow expressions"); Importer = importer; Path = path; Features = features; IsOnce = isOnce; ImportAction = Importer.Import(this); // it is assumed to be css if it cannot be found as less }
static void Main(string[] args) { var output = new ConsoleOutput(); if (args == null || args.Length == 0) { output.WriteLine("Cannot find any arguments"); return; } var actionName = args[0].ToLowerInvariant(); IAction action; switch (actionName) { case ActionList.Export: action = new ExportAction(); break; case ActionList.Import: action = new ImportAction(output); break; case ActionList.FullReset: action = new FullResetAction(); break; case ActionList.ForceClean: action = new ForceCleanAction(); break; default: output.WriteLine($"Action {actionName} is not supported"); return; } output.WriteLine("Start action..."); try { action.Execute(args).GetAwaiter().GetResult(); } catch (OptionException ex) { output.WriteLine(ex.Message); return; } output.WriteLine("Complete"); }
private Import(string path, IImporter importer, Value features, bool isOnce) { if (path == null) { throw new ParserException("Imports do not allow expressions"); } Importer = importer; Path = path; Features = features; IsOnce = isOnce; ImportAction = Importer.Import(this); // it is assumed to be css if it cannot be found as less }
// execute a given import action static private void Import(ImportAction action, ImportPackage package, Action <int, string> log, dynamic context) { try { // run dependencies foreach (var dependency in action.Dependencies.Select(d => package[d]).Where(a => !(a ?? new ImportAction()).Executed)) { try { if (dependency != null) { Import(dependency, package, log, context); } } catch { if (action.BreakOnError) { throw; } } } // run the action log.Info("{0} started", action.Name); Type providerType = Type.GetType(action.ProviderType); ImportProvider provider = providerType != null ? Activator.CreateInstance(providerType) as ImportProvider : null; if (provider == null) { if (providerType == null) { throw new Exception(string.Format("Import action provider does not exist. '{0}'", action.ProviderType)); } throw new Exception(string.Format("Invalid import action provider: '{0}'. ", action.ProviderType)); } // perform the actions outlined in the instructions provider.Import(action.Instructions, package.Data, log, context); action.Executed = true; // Provide an indicator for other references, update the action executed to true. log.Info("{0} completed", action.Name); } catch (Exception aex) { log.Error(aex.Message); log.Debug(aex, ""); log.Info("{0} aborted", action.Name); if (action.BreakOnError) { throw; } } }
/// <summary> /// Override default decision made by PD. /// </summary> public override UserRequestedImportAction OverrideSolutionImportDecision(string solutionUniqueName, Version organizationVersion, Version packageSolutionVersion, Version inboundSolutionVersion, Version deployedSolutionVersion, ImportAction systemSelectedImportAction) { // Solution appears in settings if the request came from the SPA. Follow that request if it exists. if (RuntimeSettings != null && RuntimeSettings.ContainsKey(solutionUniqueName)) { bool install = false; if (bool.TryParse((string)RuntimeSettings[solutionUniqueName], out install) && !install) { PackageLog.Log("Skipping package: " + solutionUniqueName); return(UserRequestedImportAction.Skip); } } // If this request didn't come from the SPA, then this is an upgrade, but default to allow the anchor solution. We don't want to install new solutions, // so only import the ones that already exist on the instance else if (solutionUniqueName?.Equals(ANCHOR_SOLUTION_UNIQUE_NAME) == false && deployedSolutionVersion.Equals(new Version(0, 0, 0, 0))) { return(UserRequestedImportAction.Skip); } PackageLog.Log("Not skipping package: " + solutionUniqueName); return(base.OverrideSolutionImportDecision(solutionUniqueName, organizationVersion, packageSolutionVersion, inboundSolutionVersion, deployedSolutionVersion, systemSelectedImportAction)); }
/// <summary> /// Create a evaluated node that will render a @import /// </summary> /// <param name="originalPath"></param> /// <param name="features"></param> private Import(Node originalPath, Node features) { OriginalPath = originalPath; Features = features; ImportAction = ImportAction.LeaveImport; }
private static string GetContentPartialViewName(ImportAction forAction) { return(string.Format("_{0}", Enum.GetName(forAction.GetType(), forAction))); }
public override Node Evaluate(Env env) { OriginalPath = OriginalPath.Evaluate(env); var quoted = OriginalPath as Quoted; if (quoted != null) { Path = quoted.Value; } ImportAction action = GetImportAction(env.Parser.Importer); if (action == Importers.ImportAction.ImportNothing) { return(new NodeList().ReducedFrom <NodeList>(this)); } Node features = null; if (Features) { features = Features.Evaluate(env); } if (action == ImportAction.LeaveImport) { return(new Import(OriginalPath, features)); } if (action == ImportAction.ImportCss) { var importCss = new Import(OriginalPath, null) { _importAction = ImportAction.ImportCss, InnerContent = InnerContent }; if (features) { return(new Media(features, new NodeList() { importCss })); } return(importCss); } using (env.Parser.Importer.BeginScope(this)) { if (IsReference || IsOptionSet(ImportOptions, ImportOptions.Reference)) { // Walk the parse tree and mark all nodes as references. IsReference = true; IVisitor referenceImporter = null; referenceImporter = DelegateVisitor.For <Node>(node => { var ruleset = node as Ruleset; if (ruleset != null) { if (ruleset.Selectors != null) { ruleset.Selectors.Accept(referenceImporter); ruleset.Selectors.IsReference = true; } if (ruleset.Rules != null) { ruleset.Rules.Accept(referenceImporter); ruleset.Rules.IsReference = true; } } var media = node as Media; if (media != null) { media.Ruleset.Accept(referenceImporter); } var nodeList = node as NodeList; if (nodeList != null) { nodeList.Accept(referenceImporter); } node.IsReference = true; return(node); }); Accept(referenceImporter); } NodeHelper.ExpandNodes <Import>(env, InnerRoot.Rules); } var rulesList = new NodeList(InnerRoot.Rules).ReducedFrom <NodeList>(this); if (features) { return(new Media(features, rulesList)); } return(rulesList); }
public override Node Evaluate(Env env) { OriginalPath = OriginalPath.Evaluate(env); var quoted = OriginalPath as Quoted; if (quoted != null) { Path = quoted.Value; } ImportAction action = GetImportAction(env.Parser.Importer); if (action == Importers.ImportAction.ImportNothing) { return(new NodeList().ReducedFrom <NodeList>(this)); } Node features = null; if (Features) { features = Features.Evaluate(env); } if (action == ImportAction.LeaveImport) { return(new Import(OriginalPath, features)); } if (action == ImportAction.ImportCss) { var importCss = new Import(OriginalPath, null) { _importAction = ImportAction.ImportCss, InnerContent = InnerContent }; if (features) { return(new Media(features, new NodeList() { importCss })); } return(importCss); } using (env.Parser.Importer.BeginScope(this)) { if (IsReference || IsOptionSet(ImportOptions, ImportOptions.Reference)) { // Walk the parse tree and mark all nodes as references. IsReference = true; Accept(referenceVisitor); } NodeHelper.RecursiveExpandNodes <Import>(env, InnerRoot); } var rulesList = new NodeList(InnerRoot.Rules).ReducedFrom <NodeList>(this); if (features) { return(new Media(features, rulesList)); } return(rulesList); }
public static void Import(this Application application, string devClient, string serverName, string database, ImportAction importAction = ImportAction.Default, SynchronizeSchemaChanges?synchronizeSchemaChanges = null, string navServerName = null, string navServerInstance = null, int?navServerMgtPort = null, string tenant = null) { var arguments = new Arguments("importobjects", serverName, database); arguments.AddIf(importAction != ImportAction.Default, "importaction", (int)importAction); arguments.Add("synchronizeschemachanges", synchronizeSchemaChanges?.ToString().ToLowerInvariant()); arguments.Add("navservername", navServerName); arguments.Add("navserverinstance", navServerInstance); arguments.Add("navservermanagementport", navServerMgtPort); arguments.Add("tenant", tenant); DoImport(application, devClient, arguments); }
static string GetActionName(MatchState state, ImportAction action) { switch (state) { case MatchState.Added: if (action == ImportAction.Ignore) return "Don't Add"; if (action == ImportAction.Update) return "Update existing person"; break; case MatchState.Deleted: if (action == ImportAction.Ignore) return "Keep"; break; case MatchState.Updated: if (action == ImportAction.Add) return "Create new person"; break; } return action.ToString(); }
public static void Import(this Application application, string devClient, string serverName, string database, ImportAction importAction = ImportAction.Default) { var arguments = new Arguments("importobjects", serverName, database); arguments.AddIf(importAction != ImportAction.Default, "importaction", (int)importAction); DoImport(application, devClient, arguments); }
public ResultProduct UpdateProduct() { //stt: nhập kho: NK // Xuất kho : XK var log = new MongoHistoryAPI() { APIUrl = "/api/product/updateproduct", CreateTime = DateTime.Now, Sucess = 1 }; var result = new ResultProduct() { id = "1", msg = "success" }; var requestContent = Request.Content.ReadAsStringAsync().Result; log.Content = requestContent; try { var jsonserializer = new JavaScriptSerializer(); var paser = jsonserializer.Deserialize <RequestProduct>(requestContent); // log.Content = new JavaScriptSerializer().Serialize(paser); if (!mongoHelper.checkLoginSession(paser.user, paser.token)) { throw new Exception("Tài khoản của bạn đã bị đăng nhập trên một thiết bị khác!"); } WavehouseInfo wareActionInfo = new WavehouseInfo(); var staff = db.HaiStaffs.Where(p => p.UserLogin == paser.user).FirstOrDefault(); if (staff != null) { wareActionInfo.wCode = staff.HaiBranch.Code; wareActionInfo.wName = staff.HaiBranch.Name; var userStaff = db.AspNetUsers.Where(p => p.UserName == paser.user).FirstOrDefault(); var role = userStaff.AspNetRoles.FirstOrDefault(); if (role.Name == "Warehouse") { wareActionInfo.wType = "W"; } else { wareActionInfo.wType = "B"; } } else { var agency = db.CInfoCommons.Where(p => p.UserLogin == paser.user).FirstOrDefault(); if (agency != null) { wareActionInfo.wCode = agency.CCode; wareActionInfo.wName = agency.CName; wareActionInfo.wType = agency.CType; } } // check user receiver WavehouseInfo wareReceiInfo = null; // lay thong tin noi nhan if (!String.IsNullOrEmpty(paser.receiver.Trim()) && paser.status == "XK") { wareReceiInfo = new WavehouseInfo(); var branchReceiver = db.HaiBranches.Where(p => p.Code == paser.receiver).FirstOrDefault(); if (branchReceiver != null) { wareReceiInfo.wType = "B"; wareReceiInfo.wCode = branchReceiver.Code; wareReceiInfo.wName = branchReceiver.Name; } else { var agencyReceiver = db.CInfoCommons.Where(p => p.CCode == paser.receiver).FirstOrDefault(); if (agencyReceiver != null) { wareReceiInfo.wType = agencyReceiver.CType; wareReceiInfo.wCode = agencyReceiver.CCode; wareReceiInfo.wName = agencyReceiver.CName; } } if (String.IsNullOrEmpty(wareReceiInfo.wCode) || wareActionInfo.wCode == wareReceiInfo.wCode) { throw new Exception("Sai thông tin nơi nhập hàng"); } } ProductScanAction wareAction = null; if (paser.status == "NK") { wareAction = new ImportAction(db, wareActionInfo, paser.user, null); } else if (paser.status == "XK") { wareAction = new ExportAction(db, wareActionInfo, paser.user, wareReceiInfo); } if (wareAction == null) { throw new Exception("Sai thông tin quét"); } string msg = wareAction.checkRole(); if (msg != null) { throw new Exception(msg); } // kiem tra nhap kho List <GeneralInfo> productsReturn = new List <GeneralInfo>(); foreach (string barcode in paser.products) { BarcodeHistory resultSave = wareAction.Handle(barcode); db.BarcodeHistories.Add(resultSave); db.SaveChanges(); productsReturn.Add(new GeneralInfo() { code = resultSave.Barcode, name = resultSave.ProductName, status = resultSave.Messenge, success = Convert.ToInt32(resultSave.IsSuccess) }); } result.products = productsReturn; } catch (Exception e) { result.id = "0"; result.msg = e.Message; log.Sucess = 0; } log.ReturnInfo = new JavaScriptSerializer().Serialize(result); mongoHelper.createHistoryAPI(log); return(result); }
public void Import(DataBus dataBus) { //1 Service ServiceAction serviceAction = new ServiceAction(dataBus); serviceAction.CommandLine = "db"; HttpResponseMessage response = serviceAction.DoAction(); Service serviceEntity = serviceAction.ResponseData as Service; if (serviceEntity.Threads.Count > 0) { dataBus.ThreadId = serviceEntity.Threads[0].ThreadId; } else { throw new Exception("Service action Error: no thread returned"); } string responseData = response.GetContent(); ////Get Form //GetFormAction getFormAction = new GetFormAction(dataBus); //response = getFormAction.DoAction(); //responseData = response.GetContent(); //Get Data GetDataAction getDataAction = new GetDataAction(dataBus); getDataAction.FormName = "format.prompt.db.g"; response = getDataAction.DoAction(); responseData = response.GetContent(); //Execute inport/load ExecuteAction executeAction = new ExecuteAction(dataBus); executeAction.FormName = "format.prompt.db.g"; executeAction.Type = "detail"; executeAction.EventId = 208; executeAction.ExecuteData.LoadXml("<modelChanges><focus cursorLine=\"7\" cursorLineAbs=\"10\">instance/file.name</focus></modelChanges>"); response = executeAction.DoAction(); responseData = response.GetContent(); //Get Form : import GetFormAction unloadGetFormAction = new GetFormAction(dataBus); response = unloadGetFormAction.DoAction(); responseData = response.GetContent(); //Execute import ExecuteAction importExecuteAction = new ExecuteAction(dataBus); importExecuteAction.FormName = "database.load.prompt.g"; importExecuteAction.Type = "detail"; importExecuteAction.EventId = 1; importExecuteAction.ExecuteData.LoadXml("<modelChanges></modelChanges>"); XmlElement importRootElement = importExecuteAction.ExecuteData.DocumentElement; XmlElement importVarElement = importExecuteAction.ExecuteData.CreateElement("var"); XmlElement importNameElement = importExecuteAction.ExecuteData.CreateElement("dbl.file.name"); importNameElement.AppendChild(importExecuteAction.ExecuteData.CreateTextNode(unloadLocation)); importVarElement.AppendChild(importNameElement); importRootElement.AppendChild(importVarElement); response = importExecuteAction.DoAction(); responseData = response.GetContent(); Execute executeEntity = null; do { ImportAction uploadAction = new ImportAction(dataBus); uploadAction.FileLocation = unloadLocation; response = uploadAction.DoAction(); responseData = response.GetContent(); executeEntity = uploadAction.ResponseData as Execute; ActionUtil.StoreMessages(executeEntity.ClientRequestEntity); }while (executeEntity.ClientRequestEntity.Name != "message"); while (executeEntity.ClientRequestEntity != null) { try { MessageResponseAction messageAction = new MessageResponseAction(dataBus); response = messageAction.DoAction(); // responseData = response.GetContent(); executeEntity = messageAction.ResponseData as Execute; ActionUtil.StoreMessages(executeEntity.ClientRequestEntity); } catch (Exception ex) { break; } } }
public ResultProduct HelpAgencyImport() { //stt: nhập kho: NK // Xuất kho : XK var log = new MongoHistoryAPI() { APIUrl = "/api/product/helpagencyimport", CreateTime = DateTime.Now, Sucess = 1 }; var result = new ResultProduct() { id = "1", msg = "success" }; var requestContent = Request.Content.ReadAsStringAsync().Result; log.Content = requestContent; try { var jsonserializer = new JavaScriptSerializer(); var paser = jsonserializer.Deserialize <RequestProductHelp>(requestContent); log.Content = new JavaScriptSerializer().Serialize(paser); if (!mongoHelper.checkLoginSession(paser.user, paser.token)) { throw new Exception("Tài khoản của bạn đã bị đăng nhập trên một thiết bị khác!"); } WavehouseInfo wareActionInfo = new WavehouseInfo(); var staff = db.HaiStaffs.Where(p => p.UserLogin == paser.user).FirstOrDefault(); if (staff == null) { throw new Exception("Chỉ nhân viên công ty mới sử dụng chức năng này"); } var agency = db.CInfoCommons.Where(p => p.CCode == paser.agency).FirstOrDefault(); if (agency != null) { wareActionInfo.wCode = agency.CCode; wareActionInfo.wName = agency.CName; wareActionInfo.wType = agency.CType; } else { throw new Exception("Sai mã khách hàng"); } // kiem tra toa do ProductScanAction wareAction = new ImportAction(db, wareActionInfo, paser.user, null); string msg = wareAction.checkRole(); if (msg != null) { throw new Exception(msg); } // kiem tra nhap kho List <GeneralInfo> productsReturn = new List <GeneralInfo>(); foreach (string barcode in paser.products) { BarcodeHistory resultSave = wareAction.Handle(barcode); resultSave.StaffHelp = staff.Code; if (paser.nearAgency == 1) { resultSave.StaffHelpIssue = "locationin"; } else { resultSave.StaffHelpIssue = "locationout"; } resultSave.LocationStaff = paser.latitude + "|" + paser.longitude; db.BarcodeHistories.Add(resultSave); db.SaveChanges(); productsReturn.Add(new GeneralInfo() { code = resultSave.Barcode, name = resultSave.ProductName, status = resultSave.Messenge, success = Convert.ToInt32(resultSave.IsSuccess) }); } result.products = productsReturn; } catch (Exception e) { result.id = "0"; result.msg = e.Message; log.Sucess = 0; } log.ReturnInfo = new JavaScriptSerializer().Serialize(result); mongoHelper.createHistoryAPI(log); return(result); }
public ImportStatusEventArgs(ImportAction action, List<RomMatch> newItems) { NewItems = newItems; Action = action; }
/// <summary> /// Override default decision made by PD. /// </summary> /// <param name="solutionUniqueName">Solution unique name.</param> /// <param name="organizationVersion">Organization version.</param> /// <param name="packageSolutionVersion">Package solution version.</param> /// <param name="inboundSolutionVersion">Inbound solution version.</param> /// <param name="deployedSolutionVersion">Deployed solution version.</param> /// <param name="systemSelectedImportAction">Import action.</param> /// <returns>Import action object.</returns> public override UserRequestedImportAction OverrideSolutionImportDecision(string solutionUniqueName, Version organizationVersion, Version packageSolutionVersion, Version inboundSolutionVersion, Version deployedSolutionVersion, ImportAction systemSelectedImportAction) { // Perform “Update” to the existing solution // instead of “Delete And Promote” when a new version // of an existing solution is detected. if (systemSelectedImportAction == ImportAction.Import) { return(UserRequestedImportAction.ForceUpdate); } return(base.OverrideSolutionImportDecision(solutionUniqueName, organizationVersion, packageSolutionVersion, inboundSolutionVersion, deployedSolutionVersion, systemSelectedImportAction)); }
public static void Import(this Application application, string devClient, string serverName, string database, ImportAction importAction = ImportAction.Default, bool?validateTableChanges = null, string navServerName = null, string navServerInstance = null, int?navServerMgtPort = null, string tenant = null) { var arguments = new Arguments("importobjects", serverName, database); arguments.AddIf(importAction != ImportAction.Default, "importaction", (int)importAction); arguments.AddIf(validateTableChanges.HasValue, "validatetablechanges", validateTableChanges.Value ? 1 : 0); arguments.Add("navservername", navServerName); arguments.Add("navserverinstance", navServerInstance); arguments.Add("navservermanagementport", navServerMgtPort); arguments.Add("tenant", tenant); DoImport(application, devClient, arguments); }
/// <inheritdoc/> public override UserRequestedImportAction OverrideSolutionImportDecision(string solutionUniqueName, Version organizationVersion, Version packageSolutionVersion, Version inboundSolutionVersion, Version deployedSolutionVersion, ImportAction systemSelectedImportAction) { this.ExecuteLifecycleEvent($"{nameof(this.OverrideSolutionImportDecision)}({solutionUniqueName})", () => { this.ProcessedSolutions.Add(solutionUniqueName); }); return(base.OverrideSolutionImportDecision(solutionUniqueName, organizationVersion, packageSolutionVersion, inboundSolutionVersion, deployedSolutionVersion, systemSelectedImportAction)); }
public void Import(ImportAction action) { if (IsImporting) { return; } var customer = CustomerContext.Current.GetContactById(Guid.Empty); // instantiate the import job here so that it can capture the current EventContext instance. var importJob = new ImportJob(AppContext.Current.ApplicationId, CatalogPackagePath, "Catalog.xml", true); Action importAction = () => { IsImporting = true; try { if ((action & ImportAction.SiteContent) == ImportAction.SiteContent) { _progressMessenger.AddProgressMessageText("Importing Site content...", false, 0); doImportEpiData(SiteContentPath); _progressMessenger.AddProgressMessageText("Done importing Site content.", false, 5); } if ((action & ImportAction.AssetContent) == ImportAction.AssetContent) { _progressMessenger.AddProgressMessageText("Importing Asset content...", false, 10); doImportEpiData(AssetPath); _progressMessenger.AddProgressMessageText("Done importing Asset content.", false, 15); //Reindex the asset contents to make them searchable _progressMessenger.AddProgressMessageText("Start indexing asset contents.", false, 15); ServiceLocator.Current.GetInstance<ReIndexManager>().ReIndex(); _progressMessenger.AddProgressMessageText("Done indexing asset contents.", false, 20); } #region Import catalog and asset mapping if ((action & ImportAction.CatalogContent) == ImportAction.CatalogContent) { _progressMessenger.AddProgressMessageText("Importing Catalog content...", false, 20); Action<IBackgroundTaskMessage> addMessage = msg => { var isError = msg.MessageType == BackgroundTaskMessageType.Error; var percent = (int)Math.Round(msg.GetOverallProgress() * 100); var message = msg.Exception == null ? msg.Message : string.Format("{0} {1}", msg.Message, msg.ExceptionMessage); _progressMessenger.AddProgressMessageText(message, isError, percent); }; importJob.Execute(addMessage, CancellationToken.None); _progressMessenger.AddProgressMessageText("Done importing Catalog content", false, 60); //We are running in front-end site context, the metafield update events are ignored, we need to sync manually _progressMessenger.AddProgressMessageText("Syncing metaclasses with content types", false, 60); SyncMetaClassesToContentTypeModels(); _progressMessenger.AddProgressMessageText("Done syncing metaclasses with content types", false, 70); _progressMessenger.AddProgressMessageText("Rebuilding index...", false, 70); BuildIndex(_progressMessenger, AppContext.Current.ApplicationId, AppContext.Current.ApplicationName, true); _progressMessenger.AddProgressMessageText("Done rebuilding index", false, 90); } #endregion _progressMessenger.SetProgressDone(); IsDone = true; } catch (Exception ex) { var error = ex.Message + "<br />" + ex.StackTrace; _progressMessenger.AddProgressMessageText(error, true, 0); _progressMessenger.SetProgressFailed(); IsFailed = true; _log.Error("Import failed"); _log.Error(ex); throw; } }; Task.Factory.StartNew(importAction); }