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 { } }
public void OpenSession(string url, bool forceSession) { string Login = string.Empty; string Password = string.Empty; using (AvtoritetEntities ae = new AvtoritetEntities()) { string sql = "SELECT dbo.ProviderAccount.Login, dbo.ProviderAccount.Password\r\n FROM dbo.Provider INNER JOIN\r\n dbo.ProviderAccount ON dbo.Provider.ProviderId = dbo.ProviderAccount.ProviderId\r\n WHERE(dbo.Provider.Uri LIKE N'%partslink%') AND(dbo.ProviderAccount.Enable = 1)"; System.Collections.Generic.List <ProvAcc> provider = ae.Database.SqlQuery <ProvAcc>(sql, new object[0]).ToList <ProvAcc>(); if (provider.Count > 0) { System.Random random = new System.Random(); int randomValue = (provider.Count > 1) ? random.Next(provider.Count - 1) : 0; Login = provider[randomValue].Login; Password = provider[randomValue].Password; } } this.requestHandler = RequestHandlerFactory.Create(url, Login, Password, null); HttpResponseMessage responseMessage = this.GetResponse(url, forceSession, this.requestHandler, PartslinkPortal.CookieContainer); if (responseMessage != null) { this.requestHandler.GetSessionResultAsync(responseMessage); } }
public void OpenSession(string url, bool forceSession) { string Login = string.Empty; string Password = string.Empty; using (AvtoritetEntities ae = new AvtoritetEntities()) { string sql = "SELECT TOP (1) dbo.ProviderAccount.Login, dbo.ProviderAccount.Password\r\n FROM dbo.Provider INNER JOIN\r\n dbo.ProviderAccount ON dbo.Provider.ProviderId = dbo.ProviderAccount.ProviderId\r\n WHERE(dbo.Provider.Uri LIKE N'%imtportal.gm.com/chevrolet%') AND(dbo.ProviderAccount.Enable = 1)"; ProvAcc provider = ae.Database.SqlQuery <ProvAcc>(sql, new object[0]).FirstOrDefault <ProvAcc>(); if (provider != null) { Login = provider.Login; Password = provider.Password; } } //Login = "******"; //Password = "******"; this.requestHandler = RequestHandlerFactory.Create(url, Login, Password, null); HttpResponseMessage responseMessage = this.GetResponse(url, forceSession, this.requestHandler, ChevroletPortal.CookieContainer); if (responseMessage != null) { this.requestHandler.GetSessionResultAsync(responseMessage); } }
public override void OpenSession(string url, long providerId, bool forceSession) { string url_session = string.Empty; int validateSession = -1; //uri = new Uri(url); //urlSession = string.Format("{0}://{1}/", uri.Scheme, uri.Host); url_session = url; if (!((validateSession = GetValidateSession(url_session, forceSession, ChevroletPortal.CookieContainer)) == 0)) { string login = string.Empty, password = string.Empty; if (validateSession == -1) { using (AvtoritetEntities ae = new AvtoritetEntities()) { string sql = //string.Format( ////"SELECT TOP (1) dbo.ProviderAccount.Login, dbo.ProviderAccount.Password\r\n FROM dbo.Provider INNER JOIN\r\n dbo.ProviderAccount ON dbo.Provider.ProviderId = dbo.ProviderAccount.ProviderId\r\n WHERE(dbo.Provider.Uri LIKE N'%{0}%') AND(dbo.ProviderAccount.Enable = 1)" ////, CatalogApi.UrlConstants.ChevroletOpelGroupRoot) //"SELECT TOP (1) dbo.ProviderAccount.Login, dbo.ProviderAccount.Password{0}{1}" // + "FROM dbo.Provider{0}{1}" // + "INNER JOIN dbo.ProviderAccount ON dbo.Provider.ProviderId = dbo.ProviderAccount.ProviderId{0}{1}" // + "WHERE(dbo.Provider.Uri = N'{2}') AND (dbo.ProviderAccount.Enable = 1)" // , "\r\n", " ", url_session) GetQueryCreditionals(providerId) ; ProvAcc provider = ae.Database.SqlQuery <ProvAcc>(sql, new object[0]).FirstOrDefault <ProvAcc>(); if (provider != null) { login = provider.Login; password = provider.Password; } } //uri = new Uri(url); //urlSession = string.Format("{0}://{1}/", uri.Scheme, uri.Host); url_session = url; this.m_requestHandler = RequestHandlerFactory.Create(url_session, login, password, null); } else { ; } } else { ; } HttpResponseMessage responseMessage = this.GetResponse(url_session, providerId, validateSession, this.m_requestHandler, ChevroletPortal.CookieContainer); if (responseMessage != null) { this.m_requestHandler.GetSessionResultAsync(responseMessage); } }
// GET: Group public ActionResult Index() { using (var ae = new AvtoritetEntities()) { var groups = ae.Group.OrderBy(t => t.Order).ToList(); return(View(groups)); } }
public static string CreatePathForProviderAccount(int providerId) { using (var ae = new AvtoritetEntities()) { var provider = ae.Provider.Include("Brand").FirstOrDefault(t => t.ProviderId == providerId); return(string.Format("{0} >> <a href='/ProviderAccount/?providerId={1}'>{2}</a>", CreatePathForProvider(provider.Brand.BrandId), provider.ProviderId, provider.Title)); } }
public static string CreatePathForProvider(int brandId) { using (var ae = new AvtoritetEntities()) { var brand = ae.Brand.Include("GroupBox").FirstOrDefault(t => t.BrandId == brandId); return(string.Format("{0}>> <a href='/Provider/?brandId={1}'>{2}</a> ", CreatePathForBrand(brand.GroupBoxId), brand.BrandId, brand.NameAndFolder)); } }
public static string CreatePathForGroupBox(int groupId) { using (var ae = new AvtoritetEntities()) { var group = ae.Group.FirstOrDefault(t => t.GroupId == groupId); return(string.Format("<a href='/Group/'>{0}</a> >> <a href='/GroupBox/?groupId={1}'>{2}</a>", "Группы", group.GroupId, group.Name)); } }
public static string CreatePathForBrand(int groupboxId) { using (var ae = new AvtoritetEntities()) { var groupbox = ae.GroupBox.FirstOrDefault(t => t.GroupBoxId == groupboxId); return(string.Format("{0} >> <a href='/Brand/?groupboxId={1}'>{2}</a>", CreatePathForGroupBox(groupbox.GroupId), groupbox.GroupBoxId, groupbox.Title)); } }
// GET: ProviderAccount/Edit/5 public ActionResult Edit(int providerAccId = 0, int providerId = 0) { using (var ae = new AvtoritetEntities()) { var providerAcc = ae.ProviderAccount.FirstOrDefault(t => t.ProviderAccountId == providerAccId) ?? new ProviderAccount(); ViewBag.ProviderId = providerId; return(View(providerAcc)); } }
public override void OpenSession(string url, long providerId, bool forceSession) { string url_session = url; int validateSession = -1; if (!((validateSession = GetValidateSession(url_session, forceSession, PartslinkPortal.CookieContainer)) == 0)) { string login = string.Empty , password = string.Empty; if (validateSession < 0) { using (AvtoritetEntities ae = new AvtoritetEntities()) { string sql = string.Format("SELECT dbo.ProviderAccount.Login, dbo.ProviderAccount.Password{1}{0}{0}{0}{0}" + "FROM dbo.Provider{1}{0}{0}{0}{0}" + "INNER JOIN dbo.ProviderAccount ON dbo.Provider.ProviderId = dbo.ProviderAccount.ProviderId{1}{0}{0}{0}{0}" + "WHERE(dbo.Provider.Uri LIKE N'%{2}%') AND (dbo.ProviderAccount.Enable = 1)" , " " , "\r\n" , ResourceManager.Urls[CatalogApi.UrlConstants.Key.PartslinkRoot]) //GetQueryCreditionals(providerId) ; System.Collections.Generic.List <ProvAcc> provider = ae.Database.SqlQuery <ProvAcc>(sql, new object[0]).ToList <ProvAcc>(); if (provider.Count > 0) { System.Random random = new System.Random(); int randomValue = (provider.Count > 1) ? random.Next(provider.Count - 1) : 0; login = provider[randomValue].Login; password = provider[randomValue].Password; } } this.m_requestHandler = RequestHandlerFactory.Create(url_session, login, password, null); } else { ; } } else { ; } HttpResponseMessage responseMessage = this.GetResponse(url_session, providerId, validateSession, this.m_requestHandler, PartslinkPortal.CookieContainer); if (responseMessage != null) { this.m_requestHandler.GetSessionResultAsync(responseMessage); } else { ; } }
// GET: Group/Edit/5 public ActionResult Edit(int groupId = 0) { Group group = null; using (var ae = new AvtoritetEntities()) { group = ae.Group.FirstOrDefault(t => t.GroupId == groupId) ?? new Group(); return(View(group)); } }
// GET: Brand public ActionResult Index(int groupboxId) { using (var ae = new AvtoritetEntities()) { var brands = ae.Brand.Where(t => t.GroupBoxId == groupboxId).OrderBy(t => t.NameAndFolder).ToList(); ViewBag.GroupBoxId = groupboxId; ViewBag.BradCrumb = BradCrumb.CreatePathForBrand(groupboxId); return(View(brands)); } }
// GET: GroupBox public ActionResult Index(int groupId) { using (var ae = new AvtoritetEntities()) { var groupboxs = ae.GroupBox.Where(t => t.GroupId == groupId).ToList(); ViewBag.GroupId = groupId; ViewBag.BradCrumb = BradCrumb.CreatePathForGroupBox(groupId); return(View(groupboxs)); } }
public ActionResult Index(int providerId) { using (var ae = new AvtoritetEntities()) { var providerFiles = ae.ProviderFile.Where(t => t.ProviderId == providerId).OrderBy(t => t.FileName).ToList(); ViewBag.providerId = providerId; ViewBag.BradCrumb = BradCrumb.CreatePathForProviderFile(providerId); return(View(providerFiles)); } }
// GET: Provider public ActionResult Index(int brandId = 0) { using (var ae = new AvtoritetEntities()) { var providers = ae.Provider.Where(t => t.BrandId == brandId).OrderBy(t => t.Order).ToList(); ViewBag.brandId = brandId; ViewBag.BradCrumb = BradCrumb.CreatePathForProvider(brandId); return(View(providers)); } }
// GET: GroupBox/Edit/5 public ActionResult Edit(int groupboxId = 0, int groupId = 0) { GroupBox groupbox = null; using (var ae = new AvtoritetEntities()) { groupbox = ae.GroupBox.FirstOrDefault(t => t.GroupBoxId == groupboxId) ?? new GroupBox(); ViewBag.GroupId = groupId; return(View(groupbox)); } }
public ActionResult LayOut(int groupboxid, int groupId) { using (var ae = new AvtoritetEntities()) { var groupbox = ae.GroupBox.FirstOrDefault(t => t.GroupBoxId == groupboxid); ViewBag.Width = groupbox.Width; ViewBag.Height = groupbox.Height; ViewBag.GroupId = groupId; return(View(groupboxid)); } }
// GET: Provider/Edit/5 public ActionResult Edit(int providerId = 0, int brandId = 0) { Provider provider = null; using (var ae = new AvtoritetEntities()) { provider = ae.Provider.FirstOrDefault(t => t.ProviderId == providerId) ?? new Provider(); ViewBag.BrandId = brandId; return(View(provider)); } }
public ActionResult LayOut(int groupId) { using (var ae = new AvtoritetEntities()) { var groupWidth = ae.Group.Max(t => t.Width); var groupHeight = ae.Group.Max(t => t.Height); ViewBag.Width = groupWidth; ViewBag.Height = groupHeight; return(View(groupId)); } }
public ActionResult Edit(int commandFileId = 0, int providerId = 0) { CommandFile commandFile = null; using (var ae = new AvtoritetEntities()) { commandFile = ae.CommandFile.FirstOrDefault(t => t.CommandFileId == commandFileId) ?? new CommandFile(); ViewBag.ProviderId = providerId; return(View(commandFile)); } }
// 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 ActionResult BrandImage(int id) { using (var ae = new AvtoritetEntities()) { var image = ae.Brand.FirstOrDefault(t => t.BrandId == id); if (image != null && image.IconPathImg != null) { return(File(image.IconPathImg, "image/" + (!string.IsNullOrEmpty(image.IconPathImgExt) ? image.IconPathImgExt.Substring(1) : string.Empty))); } return(null); } }
public override void OpenSession(string url, long providerId, bool forceSession) { string url_session = url; int validateSession = -1; if (!((validateSession = GetValidateSession(url_session, forceSession, PeugeotPortal.CookieContainer)) == 0)) { string login = string.Empty , password = string.Empty; if (validateSession < 0) { using (AvtoritetEntities ae = new AvtoritetEntities()) { string sql = //string.Format("SELECT TOP (1) dbo.ProviderAccount.Login, dbo.ProviderAccount.Password{0}" // + " FROM dbo.Provider{0}" // + " INNER JOIN dbo.ProviderAccount ON dbo.Provider.ProviderId = dbo.ProviderAccount.ProviderId{0}" // + " WHERE(dbo.Provider.Uri LIKE N'%peugeot%') AND(dbo.ProviderAccount.Enable = 1)" // , "\r\n") GetQueryCreditionals(providerId) ; ProvAcc provider = ae.Database.SqlQuery <ProvAcc>(sql, new object[0]).FirstOrDefault <ProvAcc>(); login = provider.Login; password = provider.Password; } this.m_requestHandler = RequestHandlerFactory.Create(url_session, login, password, null); } else { ; } } else { ; } HttpResponseMessage responseMessage = this.GetResponse(url_session, providerId, validateSession, this.m_requestHandler, PeugeotPortal.CookieContainer); if (responseMessage != null) { this.m_requestHandler.GetSessionResultAsync(responseMessage); } else { ; } }
// GET: Brand/Edit/5 public ActionResult Edit(int brandid = 0, int groupboxId = 0) { Brand brand = null; using (var ae = new AvtoritetEntities()) { brand = ae.Brand.FirstOrDefault(t => t.BrandId == brandid) ?? new Brand(); ViewBag.GroupBoxId = groupboxId; ViewBag.StyleList = GetButtonStyles(brand.ButtonStyle); return(View(brand)); } }
public ActionResult GetCommandFiles(int providerId) { using (var ae = new AvtoritetEntities()) { var commandFiles = ae.CommandFile.Where(t => t.ProviderId == providerId).Select(t => new { commandFileId = t.CommandFileId, providerId = t.ProviderId, filename = t.FileName }).ToList(); return(Json(commandFiles, JsonRequestBehavior.AllowGet)); } }
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); }