Ejemplo n.º 1
0
 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
     {
     }
 }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
 // GET: Group
 public ActionResult Index()
 {
     using (var ae = new AvtoritetEntities())
     {
         var groups = ae.Group.OrderBy(t => t.Order).ToList();
         return(View(groups));
     }
 }
Ejemplo n.º 6
0
 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));
     }
 }
Ejemplo n.º 7
0
 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));
     }
 }
Ejemplo n.º 8
0
 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));
     }
 }
Ejemplo n.º 9
0
 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));
     }
 }
Ejemplo n.º 10
0
 // 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));
     }
 }
Ejemplo n.º 11
0
        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
            {
                ;
            }
        }
Ejemplo n.º 12
0
        // 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));
            }
        }
Ejemplo n.º 13
0
 // 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));
     }
 }
Ejemplo n.º 14
0
 // 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));
     }
 }
Ejemplo n.º 15
0
 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));
     }
 }
Ejemplo n.º 16
0
 // 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));
     }
 }
Ejemplo n.º 17
0
        // 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));
            }
        }
Ejemplo n.º 18
0
 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));
     }
 }
Ejemplo n.º 19
0
        // 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));
            }
        }
Ejemplo n.º 20
0
        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));
            }
        }
Ejemplo n.º 21
0
        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));
            }
        }
Ejemplo n.º 22
0
 // 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 }));
     }
 }
Ejemplo n.º 23
0
 // 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 }));
     }
 }
Ejemplo n.º 24
0
 // 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 }));
     }
 }
Ejemplo n.º 25
0
 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"));
     }
 }
Ejemplo n.º 26
0
 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);
     }
 }
Ejemplo n.º 27
0
        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
            {
                ;
            }
        }
Ejemplo n.º 28
0
        // 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));
            }
        }
Ejemplo n.º 29
0
        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));
            }
        }
Ejemplo n.º 30
0
        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);
        }