/// <summary> /// We add plugin location & reset plugin cache XML /// </summary> public void Install(string FilePath) { InstallationPath = FilePath; string spPath = FindSmartpointPath(); string otherSpPath = OtherSmartpointPath(); string pluginLocation = Path.Combine(spPath, "PluginLocations"); string otherSPLocation = otherSpPath + "\\PluginLocations"; if (Directory.Exists(pluginLocation)) { File.Copy(Path.Combine(InstallationPath, string.Format("{0}.xml", PluginName)), Path.Combine(pluginLocation, string.Format("{0}.xml", PluginName)), true); string content = GetStreamContent(Path.Combine(pluginLocation, string.Format("{0}.xml", PluginName)), 1024); try { content = content.Replace("PLACEHOLDER_TEXT", InstallationPath); StreamWriter wr = new StreamWriter(Path.Combine(pluginLocation, string.Format("{0}.xml", PluginName))); wr.Write(content); wr.Close(); } catch (Exception ex) { throw ex; } } if (Directory.Exists(otherSPLocation)) { File.Copy(Path.Combine(InstallationPath, string.Format("{0}.xml", PluginName)), Path.Combine(otherSPLocation, string.Format("{0}.xml", PluginName)), true); string content = GetStreamContent(Path.Combine(otherSPLocation, string.Format("{0}.xml", PluginName)), 1024); try { content = content.Replace("PLACEHOLDER_TEXT", InstallationPath); StreamWriter wr = new StreamWriter(Path.Combine(otherSPLocation, string.Format("{0}.xml", PluginName))); wr.Write(content); wr.Close(); } catch (Exception ex) { throw ex; } } if (Directory.Exists(pluginLocation) || Directory.Exists(otherSPLocation)) { var installationpath = Path.Combine(InstallationPath, string.Format("{0}.xml", PluginName)); var installationpathfile = new FileInfo(installationpath); installationpathfile.IsReadOnly = false; installationpathfile.Delete(); SmartpointHelper.DeletePluginCache(); } }
/// <summary> /// Finds Smartpoint install Path /// </summary> /// <returns></returns> private string FindSmartpointPath() { string sSmartpointPath = string.Empty; try { string spExePath = SmartpointHelper.GetSmartpointPath(); FileInfo exeFile = new FileInfo(spExePath); if (exeFile.Exists) { sSmartpointPath = exeFile.Directory.FullName; } } catch (Exception ex) { throw ex; //added by Pavan on 06-OCT, 2015 } return(sSmartpointPath); }
/// <summary> /// We move plugin location /// </summary> public void UnInstall() { string spPath = FindSmartpointPath(); string otherSpPath = OtherSmartpointPath(); string pluginLocation = Path.Combine(spPath, "PluginLocations"); string otherSPLocation = otherSpPath + "\\PluginLocations"; if (Directory.Exists(pluginLocation)) { var pluginFile = new FileInfo(Path.Combine(pluginLocation, string.Format("{0}.xml", PluginName))); pluginFile.IsReadOnly = false; pluginFile.Delete(); } if (Directory.Exists(otherSPLocation)) { var pluginFile = new FileInfo(Path.Combine(otherSPLocation, string.Format("{0}.xml", PluginName))); pluginFile.IsReadOnly = false; pluginFile.Delete(); } SmartpointHelper.DeletePluginCache(); }