/// <summary> /// Show updates. /// </summary> /// <param name="owner"></param> /// <param name="showAddins">Are addIns show or only application updates.</param> /// <param name="onlyNew"></param> /// <param name="DisabledItems">collection of disabled addins.</param> /// <returns></returns> public static ProtocolUpdateStatus ShowUpdates(System.Windows.Forms.IWin32Window owner, bool showAddins, bool onlyNew, out string[] DisabledItems) { GXAddInList localAddins; string path = Path.Combine(GXCommon.ProtocolAddInsPath, "updates.xml"); DataContractSerializer x = new DataContractSerializer(typeof(GXAddInList)); lock (m_sync) { if (!System.IO.File.Exists(path)) { localAddins = new GXAddInList(); } else { try { using (FileStream reader = new FileStream(path, FileMode.Open)) { localAddins = (GXAddInList)x.ReadObject(reader); } } catch (Exception) { try { File.Delete(path); } catch { //It's OK if this fails. } localAddins = new GXAddInList(); } } } AddInsForm dlg = new AddInsForm(localAddins, showAddins, onlyNew); if (dlg.ShowDialog(owner) == System.Windows.Forms.DialogResult.OK) { List <string> items = new List <string>(); foreach (GXAddIn it in localAddins) { if (it.Type == GXAddInType.AddIn && (it.State & AddInStates.Disabled) != 0) { items.Add(it.Name); } } DisabledItems = items.ToArray(); return(dlg.Status); } DisabledItems = new string[0]; return(ProtocolUpdateStatus.None); }
static public void CheckUpdates(object target) { AddInsForm form = target as AddInsForm; GXAddInList list = GXUpdateChecker.GetUpdatesOnline(!form.ShowAddins); if (list.Count != 0) { if (form.IsHandleCreated) { form.BeginInvoke(new CheckUpdatesEventHandler(form.OnCheckUpdatesDone), list); } } }
/// <summary> /// Show updates. /// </summary> /// <param name="owner"></param> /// <param name="showAddins">Are addIns show or only application updates.</param> /// <param name="onlyNew"></param> /// <param name="DisabledItems">collection of disabled addins.</param> /// <returns></returns> public static ProtocolUpdateStatus ShowUpdates(System.Windows.Forms.IWin32Window owner, bool showAddins, bool onlyNew, out string[] DisabledItems) { GXAddInList localAddins; string path = Path.Combine(GXCommon.ProtocolAddInsPath, "updates.xml"); DataContractSerializer x = new DataContractSerializer(typeof(GXAddInList)); lock (m_sync) { if (!System.IO.File.Exists(path)) { localAddins = new GXAddInList(); } else { try { using (FileStream reader = new FileStream(path, FileMode.Open)) { localAddins = (GXAddInList)x.ReadObject(reader); } } catch (Exception) { try { File.Delete(path); } catch { //It's OK if this fails. } localAddins = new GXAddInList(); } } } AddInsForm dlg = new AddInsForm(localAddins, showAddins, onlyNew); if (dlg.ShowDialog(owner) == System.Windows.Forms.DialogResult.OK) { List<string> items = new List<string>(); foreach (GXAddIn it in localAddins) { if (it.Type == GXAddInType.AddIn && (it.State & AddInStates.Disabled) != 0) { items.Add(it.Name); } } DisabledItems = items.ToArray(); return dlg.Status; } DisabledItems = new string[0]; return ProtocolUpdateStatus.None; }