public static void AddErrorInLog(string NameError, string DescrError) { try { using (AvtoritetEntities entities = new AvtoritetEntities()) { LogErrors entity = new LogErrors(); string hostName = Dns.GetHostName(); string str2 = ""; for (int i = 0; i < Dns.GetHostEntry(hostName).AddressList.Length; i++) { if (!Dns.GetHostEntry(hostName).AddressList[i].IsIPv6LinkLocal) { if (str2 != "") { str2 = str2 + ", "; } str2 = str2 + Dns.GetHostEntry(hostName).AddressList[i].ToString(); } } string userName = Environment.UserName; string machineName = Environment.MachineName; entity.Computer = hostName + ", " + str2 + ", " + userName + ", " + machineName; entity.DateError = new DateTime?(DateTime.Now); entity.ExeName = "Лаунчер"; entity.NameError = NameError; entity.DescrError = DescrError; entities.LogErrors.Add(entity); entities.SaveChanges(); } } catch { } }
// GET: Brand/Delete/5 public ActionResult Delete(int id, int groupboxId) { using (var ae = new AvtoritetEntities()) { var brand = ae.Brand.FirstOrDefault(t => t.BrandId == id); if (brand != null) { ae.Brand.Remove(brand); ae.SaveChanges(); } return(RedirectToAction("Index", new { groupboxId = groupboxId })); } }
// GET: Brand/Delete/5 public ActionResult Delete(int id, int providerId) { using (var ae = new AvtoritetEntities()) { var providerFile = ae.ProviderFile.FirstOrDefault(t => t.ProviderFileId == id); if (providerFile != null) { ae.ProviderFile.Remove(providerFile); ae.SaveChanges(); } return(RedirectToAction("Index", new { providerId = providerId })); } }
// GET: Group/Delete/5 public ActionResult Delete(int id) { using (var ae = new AvtoritetEntities()) { var groupbox = ae.GroupBox.FirstOrDefault(t => t.GroupBoxId == id); if (groupbox != null) { ae.GroupBox.Remove(groupbox); ae.SaveChanges(); } return(RedirectToAction("Index", new { groupbox.GroupId })); } }
public ActionResult Publish() { using (var ae = new AvtoritetEntities()) { var settingUpdate = ae.SettingUpdate.FirstOrDefault(); if (settingUpdate != null) { settingUpdate.Update = false; settingUpdate.SettingVersion += 1; ae.SaveChanges(); } return(RedirectToAction("Index")); } }
public string DownloadGuiSettigs() { string result; try { lock (RequestProcessor.SyncLoadGuiSettings) { using (AvtoritetEntities ae = new AvtoritetEntities()) { SettingUpdate updateFlag = ae.SettingUpdate.FirstOrDefault <SettingUpdate>(); string settings = string.Empty; string baseDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string root = System.IO.Path.Combine(baseDir, ResourceManager.Root); string path = string.Join("\\", new string[] { root, "settingui.zip" }); if (updateFlag != null && (!updateFlag.Update || !System.IO.File.Exists(path))) { settings = RequestProcessor.ReadConfigToString(); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } System.IO.File.WriteAllText(path, settings, System.Text.Encoding.Unicode); updateFlag.Update = true; ae.SaveChanges(); } else if (System.IO.File.Exists(path)) { settings = System.IO.File.ReadAllText(path, System.Text.Encoding.Unicode); } else { settings = null; } result = settings; } } } catch (System.Exception ex) { ErrorLogHelper.AddErrorInLog("DownloadGuiSettigs()", ex.Message + "|" + ex.StackTrace); result = string.Format("[{0}] {1} / {2}", System.DateTime.Now, ex.Message, ex.StackTrace); } return(result); }
public ActionResult Edit(int providerId, int brandId, bool enable, FormCollection collection) { try { using (var ae = new AvtoritetEntities()) { Provider provider = null; if (providerId == 0) { provider = new Provider { Uri = collection["Uri"], Title = collection["Title"], //IconPath = collection["IconPath"], BrandId = brandId, commandcontent = collection["commandcontent"], Enable = enable, Order = !string.IsNullOrEmpty(collection["order"])?int.Parse(collection["order"]):0 }; UploadProviderFile(provider, collection); ae.Provider.Add(provider); } else { provider = ae.Provider.FirstOrDefault(t => t.ProviderId == providerId); if (provider != null) { provider.Title = collection["Title"]; //provider.IconPath = collection["IconPath"]; provider.Uri = collection["Uri"]; provider.commandcontent = collection["commandcontent"]; provider.Enable = enable; provider.Order = !string.IsNullOrEmpty(collection["order"]) ? int.Parse(collection["order"]) : 0; } UploadProviderFile(provider, collection); } ae.SaveChanges(); return(RedirectToAction("Index", new { BrandId = brandId })); } } catch { return(View()); } }
public static void AddErrorInLog(string NameError, string DescrError) { try { using (AvtoritetEntities entities = new AvtoritetEntities()) { LogErrorsSet entity = new LogErrorsSet(); string hostName = Dns.GetHostName(); string str2 = ""; for (int i = 0; i < Dns.GetHostEntry(hostName).AddressList.Length; i++) { if (!Dns.GetHostEntry(hostName).AddressList[i].IsIPv6LinkLocal) { if (str2 != "") { str2 = str2 + ", "; } str2 = str2 + Dns.GetHostEntry(hostName).AddressList[i].ToString(); } } string userName = Environment.UserName; string machineName = Environment.MachineName; entity.Computer = hostName + ", " + str2 + ", " + userName + ", " + machineName; entity.DateError = new DateTime?(DateTime.Now); entity.ExeName = "Лаунчер"; entity.NameError = NameError; entity.DescrError = DescrError; entities.LogErrorsSet.Add(entity); entities.SaveChanges(); } } catch (Exception e) { MainWindow.Logging(e); if (!(Application.Current == null)) { Application.Current.Shutdown(-1); } else { ; } } }
public ActionResult Edit(int providerAccId, int providerId, bool enable, FormCollection collection) { try { using (var ae = new AvtoritetEntities()) { ProviderAccount providerAcc = null; if (providerAccId == 0) { providerAcc = new ProviderAccount { Uri = collection["Uri"], Login = collection["Login"], Password = collection["Password"], ProviderId = providerId, Enable = enable, Order = !string.IsNullOrEmpty(collection["order"]) ? int.Parse(collection["order"]) : 0 }; ae.ProviderAccount.Add(providerAcc); } else { providerAcc = ae.ProviderAccount.FirstOrDefault(t => t.ProviderId == providerId); if (providerAcc != null) { providerAcc.Uri = collection["Uri"]; providerAcc.Login = collection["Login"]; providerAcc.Password = collection["Password"]; providerAcc.Enable = enable; providerAcc.Order = !string.IsNullOrEmpty(collection["order"]) ? int.Parse(collection["order"]) : 0; } } ae.SaveChanges(); return(RedirectToAction("Index", new { ProviderId = providerId })); } } catch { return(View()); } }
public static void AddErrorInLog(string NameError, string DescrError) { try { using (AvtoritetEntities ae = new AvtoritetEntities()) { LogErrors log = new LogErrors(); string myHost = Dns.GetHostName(); string compIP = ""; for (int i = 0; i < Dns.GetHostEntry(myHost).AddressList.Length; i++) { if (!Dns.GetHostEntry(myHost).AddressList[i].IsIPv6LinkLocal) { if (compIP != "") { compIP += ", "; } compIP += Dns.GetHostEntry(myHost).AddressList[i].ToString(); } } string userNameWin = Environment.UserName; string compName = Environment.MachineName; log.Computer = string.Concat(new string[] { myHost, ", ", compIP, ", ", userNameWin, ", ", compName }); log.DateError = new DateTime?(DateTime.Now); log.ExeName = "Прокси сервер"; log.NameError = NameError; log.DescrError = DescrError; ae.LogErrors.Add(log); ae.SaveChanges(); } } catch { } }
public ActionResult Upload(int providerId, FormCollection collection) { try { using (var ae = new AvtoritetEntities()) { ProviderFile providerFile = new ProviderFile(); UploadProviderFile(providerFile, collection); providerFile.ProviderId = providerId; ae.ProviderFile.Add(providerFile); ae.SaveChanges(); return(RedirectToAction("Index", new { providerId = providerId })); } } catch { return(View("Index")); } }
public ActionResult SetGroupBoxCoord(string groupboxCoord) { var b = JsonConvert.DeserializeObject <List <GroupBoxCoord> >(groupboxCoord); using (var ae = new AvtoritetEntities()) { foreach (var coord in b) { var groupbox = ae.GroupBox.FirstOrDefault(t => t.GroupBoxId == coord.groupboxId); if (groupbox != null) { groupbox.Top = coord.t; groupbox.Left = coord.l; groupbox.Width = coord.w; groupbox.Height = coord.h; } } ae.SaveChanges(); } return(Json("Ok")); }
public ActionResult SetBrandCoord(string brandCoord) { List <BrandCoord> b = JsonConvert.DeserializeObject <List <BrandCoord> >(brandCoord); using (var ae = new AvtoritetEntities()) { foreach (var coord in b) { var brand = ae.Brand.FirstOrDefault(t => t.BrandId == coord.brandId); if (brand != null) { brand.Top = coord.t; brand.Left = coord.l; brand.Width = coord.w; brand.Height = coord.h; } } ae.SaveChanges(); } return(Json("Ok")); }
public ActionResult Edit(int commandFileId, int ProviderId, FormCollection collection) { try { using (var ae = new AvtoritetEntities()) { CommandFile newCommandFile = null; if (commandFileId == 0) { newCommandFile = new CommandFile { FileName = collection["filename"], ProviderId = ProviderId, FileContent = collection["filecontent"] }; ae.CommandFile.Add(newCommandFile); } else { newCommandFile = ae.CommandFile.FirstOrDefault(t => t.CommandFileId == commandFileId); if (newCommandFile != null) { newCommandFile.FileName = collection["FileName"]; newCommandFile.FileContent = collection["FileContent"]; } } ae.SaveChanges(); return(RedirectToAction("Index", new { ProviderId = ProviderId })); } } catch { return(View()); } }
public ActionResult Edit(int groupId, bool enable, FormCollection collection) { try { using (var ae = new AvtoritetEntities()) { Group newGroup = null; if (groupId == 0) { newGroup = new Group { Name = collection["Name"], Width = !string.IsNullOrEmpty(collection["Width"]) ? int.Parse(collection["Width"]) : 0, Height = !string.IsNullOrEmpty(collection["Height"]) ? int.Parse(collection["Height"]) : 0, Description = collection["Description"], Enable = enable, Order = !string.IsNullOrEmpty(collection["order"])?int.Parse(collection["order"]):0 }; ae.Group.Add(newGroup); } else { newGroup = ae.Group.FirstOrDefault(t => t.GroupId == groupId); if (newGroup != null) { newGroup.Name = collection["Name"]; newGroup.Width = !string.IsNullOrEmpty(collection["Width"]) ? int.Parse(collection["Width"]) : 0; newGroup.Height = !string.IsNullOrEmpty(collection["Height"]) ? int.Parse(collection["Height"]) : 0; newGroup.Description = collection["Description"]; newGroup.Enable = enable; newGroup.Order = !string.IsNullOrEmpty(collection["order"]) ? int.Parse(collection["order"]) : 0; } } ae.SaveChanges(); //выравнивание var groups = ae.Group.ToList(); foreach (var group in groups) { group.Height = newGroup.Height; group.Width = newGroup.Width; } ae.SaveChanges(); return(RedirectToAction("Index")); } } catch { return(View()); } }
public ActionResult ButtonAutoLayout(int groupboxid) { using (var ae = new AvtoritetEntities()) { //buttons var buttons = ae.Brand.Where(t => t.GroupBoxId == groupboxid && t.Enable).OrderBy(t => t.Order).ToList(); var groupbox = ae.GroupBox.FirstOrDefault(t => t.GroupBoxId == groupboxid); var groupboxCount = ae.GroupBox.Count(t => t.GroupId == groupbox.GroupId); if (buttons.Count > 0) { var maxWidth = (groupboxCount == 1)?ae.Group.Max(t => t.Width):groupbox.Width; var maxHeight = (groupboxCount == 1)?ae.Group.Max(t => t.Height):groupbox.Height; var rowCount = Math.Floor( (decimal) ((maxHeight - 2 * groupbox.ButtonVerticalPadding) / (groupbox.ButtonHeight + groupbox.ButtonBetweenVerticalPadding))); if (rowCount == 0) { rowCount = 1; } var colCount = (int)Math.Ceiling(buttons.Count / rowCount); if (colCount == 0) { colCount = 1; } var col = 1; var row = 1; for (var i = 0; i < buttons.Count; i++) { if (row == 1) { buttons[i].Top = groupbox.ButtonVerticalPadding; buttons[i].Left = groupbox.ButtonHorizontalPadding + (col - 1) * (groupbox.ButtonWidth + groupbox.ButtonBetweenHorizontalPadding); buttons[i].Width = groupbox.ButtonWidth; buttons[i].Height = groupbox.ButtonHeight; } else { buttons[i].Top = buttons[i - 1].Top + groupbox.ButtonHeight + groupbox.ButtonBetweenVerticalPadding - 1; buttons[i].Left = groupbox.ButtonHorizontalPadding + (col - 1) * (groupbox.ButtonWidth + groupbox.ButtonBetweenHorizontalPadding); buttons[i].Width = groupbox.ButtonWidth; buttons[i].Height = groupbox.ButtonHeight; } row++; if (row > rowCount) { col++; row = 1; } } if (groupboxCount == 1) { groupbox.Width = maxWidth; groupbox.Height = maxHeight; } else { if (col > 1) { groupbox.Height = maxHeight; } else { groupbox.Height = buttons[buttons.Count - 1].Top + groupbox.ButtonHeight + groupbox.ButtonVerticalPadding + buttons.Count * 1 + 10; } groupbox.Width = (2 * groupbox.ButtonHorizontalPadding + colCount * (groupbox.ButtonWidth + groupbox.ButtonBetweenHorizontalPadding)); } ae.SaveChanges(); } return(RedirectToAction("Index", "GroupBox", new { groupId = groupbox.GroupId })); } }
public ActionResult Edit(int brandId, int groupboxId, bool enable, bool menuwindow, FormCollection collection) { try { using (var ae = new AvtoritetEntities()) { Brand newBrand = null; if (brandId == 0) { newBrand = new Brand { NameAndFolder = collection["NameAndFolder"], //IconPath = collection["IconPath"], //IconPath2 = collection["IconPath"], GroupBoxId = groupboxId, Enable = enable, MenuWindow = menuwindow, Top = !string.IsNullOrEmpty(collection["Top"]) ? int.Parse(collection["Top"]) : 0, Left = !string.IsNullOrEmpty(collection["Left"]) ? int.Parse(collection["Left"]) : 0, Width = !string.IsNullOrEmpty(collection["Width"]) ? int.Parse(collection["Width"]) : 0, Height = !string.IsNullOrEmpty(collection["Height"]) ? int.Parse(collection["Height"]) : 0, Order = !string.IsNullOrEmpty(collection["Order"]) ? int.Parse(collection["Order"]) : 0, ButtonStyle = !string.IsNullOrEmpty(collection["ButtonStyle"]) ? collection["ButtonStyle"] :string.Empty }; UploadBrandFile(newBrand, collection); ae.Brand.Add(newBrand); } else { newBrand = ae.Brand.FirstOrDefault(t => t.BrandId == brandId); if (newBrand != null) { newBrand.NameAndFolder = collection["NameAndFolder"]; //newBrand.IconPath = collection["IconPath"]; //newBrand.IconPath2 = collection["IconPath2"]; newBrand.Enable = enable; newBrand.MenuWindow = menuwindow; newBrand.Top = !string.IsNullOrEmpty(collection["Top"]) ? int.Parse(collection["Top"]) : 0; newBrand.Left = !string.IsNullOrEmpty(collection["Left"]) ? int.Parse(collection["Left"]) : 0; newBrand.Width = !string.IsNullOrEmpty(collection["Width"]) ? int.Parse(collection["Width"]) : 0; newBrand.Height = !string.IsNullOrEmpty(collection["Height"]) ? int.Parse(collection["Height"]) : 0; newBrand.Order = !string.IsNullOrEmpty(collection["Order"]) ? int.Parse(collection["Order"]) : 0; newBrand.ButtonStyle = !string.IsNullOrEmpty(collection["ButtonStyle"]) ? collection["ButtonStyle"] : string.Empty; } UploadBrandFile(newBrand, collection); } ae.SaveChanges(); return(RedirectToAction("Index", new { GroupBoxId = groupboxId })); } } catch { return(View()); } }
public ActionResult Edit(int groupBoxId, int groupId, bool enable, bool VisibleBorder, FormCollection collection) { try { using (var ae = new AvtoritetEntities()) { GroupBox newGroupBox = null; if (groupBoxId == 0) { newGroupBox = new GroupBox { GroupId = groupId, Title = collection["Title"], Enable = enable, Top = !string.IsNullOrEmpty(collection["Top"]) ? int.Parse(collection["Top"]) : 0, Left = !string.IsNullOrEmpty(collection["Left"]) ? int.Parse(collection["Left"]) : 0, Height = !string.IsNullOrEmpty(collection["Height"]) ? int.Parse(collection["Height"]) : 0, Width = !string.IsNullOrEmpty(collection["Width"]) ? int.Parse(collection["Width"]) : 0, VisibleBorder = VisibleBorder, ButtonHeight = !string.IsNullOrEmpty(collection["ButtonHeight"]) ? int.Parse(collection["ButtonHeight"]) : 0, ButtonWidth = !string.IsNullOrEmpty(collection["ButtonWidth"]) ? int.Parse(collection["ButtonWidth"]) : 0, ButtonHorizontalPadding = !string.IsNullOrEmpty(collection["ButtonHorizontalPadding"]) ? int.Parse(collection["ButtonHorizontalPadding"]) : 0, ButtonVerticalPadding = !string.IsNullOrEmpty(collection["ButtonVerticalPadding"]) ? int.Parse(collection["ButtonVerticalPadding"]) : 0, ButtonBetweenVerticalPadding = !string.IsNullOrEmpty(collection["ButtonBetweenVerticalPadding"]) ? int.Parse(collection["ButtonBetweenVerticalPadding"]) : 0, ButtonBetweenHorizontalPadding = !string.IsNullOrEmpty(collection["ButtonBetweenHorizontalPadding"]) ? int.Parse(collection["ButtonBetweenHorizontalPadding"]) : 0 }; ae.GroupBox.Add(newGroupBox); } else { newGroupBox = ae.GroupBox.FirstOrDefault(t => t.GroupBoxId == groupBoxId); if (newGroupBox != null) { newGroupBox.GroupId = groupId; newGroupBox.Title = collection["Title"]; newGroupBox.Enable = enable; newGroupBox.VisibleBorder = VisibleBorder; newGroupBox.Top = !string.IsNullOrEmpty(collection["Top"]) ? int.Parse(collection["Top"]) : 0; newGroupBox.Left = !string.IsNullOrEmpty(collection["Left"]) ? int.Parse(collection["Left"]) : 0; newGroupBox.Height = !string.IsNullOrEmpty(collection["Height"]) ? int.Parse(collection["Height"]) : 0; newGroupBox.Width = !string.IsNullOrEmpty(collection["Width"]) ? int.Parse(collection["Width"]) : 0; newGroupBox.ButtonHeight = !string.IsNullOrEmpty(collection["ButtonHeight"]) ? int.Parse(collection["ButtonHeight"]) : 0; newGroupBox.ButtonWidth = !string.IsNullOrEmpty(collection["ButtonWidth"]) ? int.Parse(collection["ButtonWidth"]) : 0; newGroupBox.ButtonHorizontalPadding = !string.IsNullOrEmpty(collection["ButtonHorizontalPadding"]) ? int.Parse(collection["ButtonHorizontalPadding"]) : 0; newGroupBox.ButtonVerticalPadding = !string.IsNullOrEmpty(collection["ButtonVerticalPadding"]) ? int.Parse(collection["ButtonVerticalPadding"]) : 0; newGroupBox.ButtonBetweenVerticalPadding = !string.IsNullOrEmpty(collection["ButtonBetweenVerticalPadding"]) ? int.Parse(collection["ButtonBetweenVerticalPadding"]) : 0; newGroupBox.ButtonBetweenHorizontalPadding = !string.IsNullOrEmpty(collection["ButtonBetweenHorizontalPadding"]) ? int.Parse(collection["ButtonBetweenHorizontalPadding"]) : 0; } } ae.SaveChanges(); return(RedirectToAction("Index", new { groupId })); } } catch (Exception ex) { return(View()); } }