Beispiel #1
0
        protected void btn_sure_Click(object sender, EventArgs e)
        {
            Brand         brand    = this.AddBrand();
            BrandProvider provider = new BrandProvider();

            switch (this.OperationFlag)
            {
            case Operation.Add:
                if (this.IsSame() == 1)
                {
                    break;
                }
                if (provider.Insert(brand))
                {
                    this.Alert("添加成功!!!");
                    this.TextCancel();
                }
                break;

            case Operation.Update:
                if (provider.Update(brand))
                {
                    this.Alert("修改成功!!!");
                    this.BindText();
                }
                break;
            }
        }
Beispiel #2
0
        private void NewBrowserLauncherView(BrandProvider brandProvider)
        {
            brandProvider.Login    = SettingsFactory.GetLoginFromDB(brandProvider.ProviderId);
            brandProvider.Password = SettingsFactory.GetPswFromDB(brandProvider.ProviderId);

            EventNewBrowserLauncherView?.Invoke(this.time, brandProvider);
        }
Beispiel #3
0
        private void AddLaunchButton(Brand newBrand, BrandProvider provider)
        {
            ButtonModel item = CreateLaunchButton(newBrand, provider);

            item.Click += new RoutedEventHandler(this.button_onClick);
            this.categories.Add(item);
        }
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int rowIndex = e.RowIndex;

            Brand brand = new Brand();

            brand.Brand_id = Convert.ToInt32(this.GridView1.DataKeys[rowIndex].Value);

            BrandProvider provider = new BrandProvider();

            if (provider.Delete(brand))
            {
                this.Alert("删除成功!!!");

                if (this.txt_Name.Text == "")
                {
                    this.ListPager1.RecordCount = this.ListPager1.RecordCount - 1;
                    this.BindSource(null);
                }
                else
                {
                    this.ListPager1.RecordCount = this.ListPager1.RecordCount - 1;
                    this.BindSource("%" + this.txt_Name.Text + "%");
                }
            }
        }
Beispiel #5
0
        private void BindDDL()
        {
            BrandProvider brand = new BrandProvider();

            this.ddl_BrandName.DataSource = brand.GetAll();
            this.ddl_BrandName.DataBind();
            this.ddl_BrandName.Items.Add("所有");
            this.ddl_BrandName.SelectedIndex = this.ddl_BrandName.Items.Count - 1;
        }
        private void BindDDL()
        {
            UnitProvider unit = new UnitProvider();

            this.ddl_Unit.DataSource = unit.GetAll();
            this.ddl_Unit.DataBind();
            BrandProvider brand = new BrandProvider();

            this.ddl_BrandName.DataSource = brand.GetAll();
            this.ddl_BrandName.DataBind();
        }
        protected void btn_Result_Click(object sender, EventArgs e)
        {
            Brand brand = new Brand();

            brand.Brand_name = "%" + this.txt_Name.Text + "%";
            BrandProvider provider = new BrandProvider();

            this.ListPager1.RecordCount = provider.GetSize(brand);
            this.BindSource(0, "%" + this.txt_Name.Text + "%");
            this.ListPager1.PageChange += new PagerEventHandler(ListPager1_PageChange);
        }
        public SignatureFileBehaviour(IConfiguration config, ModParser parser, BrandProvider brand, AppInfoProvider info)
        {
            var section      = config.GetSection("SignatureFiles");
            var requestEmbed = config.GetValue <bool>("RequestEmbed", true);

            _files = section.Exists() ? section.Get <List <string> >() : new List <string>();
            _enableRequestEmbed = requestEmbed;
            _parser             = parser;
            _brand = brand;
            _info  = info;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         BrandProvider provider = new BrandProvider();
         this.ListPager1.RecordCount = provider.GetSize();
         this.BindSource(0, null);
     }
     this.account.Text           = Session["LOGINED"].ToString();
     this.datetime.Text          = this.BindDayWeek();
     this.ListPager1.PageChange += new PagerEventHandler(ListPager1_PageChange);
 }
Beispiel #10
0
        private void BindText()
        {
            Brand brand = new Brand();

            brand.Brand_id = Convert.ToInt32(id);
            BrandProvider provider = new BrandProvider();
            DataTable     table    = new DataTable();

            table = provider.Select(brand);

            this.txt_name.Text = table.Rows[0]["brand_name"].ToString();
        }
Beispiel #11
0
        private void BindSource()
        {
            UnitProvider unit = new UnitProvider();

            this.ddl_Unit.DataSource = unit.GetAll();
            this.ddl_Unit.DataBind();
            ProductProvider product = new ProductProvider();

            this.ddl_Product.DataSource = product.GetAll();
            this.ddl_Product.DataBind();
            BrandProvider brand = new BrandProvider();

            this.ddl_BrandName.DataSource = brand.GetAll();
            this.ddl_BrandName.DataBind();
        }
Beispiel #12
0
        private static ButtonModel CreateLaunchButton(Brand brand, BrandProvider provider)
        {
            string uri = (provider.Uri.StartsWith("http") || provider.Uri.StartsWith("https")) ? provider.Uri : Path.Combine(ResourceManager.Root, brand.NameAndFolder, provider.Uri);

            try
            {
                if (((!provider.Uri.StartsWith("http") && !provider.Uri.StartsWith("https")) && ((provider.Uri.IndexOf(@"\") >= 0) & (provider.Uri.ToLower().IndexOf(".exe") >= 0))) && File.Exists(provider.Uri))
                {
                    uri = provider.Uri;
                }
            }
            catch
            {
            }
            return(new ButtonModel {
                Height = 40.0, HorizontalContentAlignment = HorizontalAlignment.Center, Margin = new Thickness(0.0, 0.0, 0.0, 0.0), Content = provider.Title, DataContext = uri, Login = provider.Login, Password = provider.Password, ButtonStyle = brand.ButtonStyle, ProviderId = provider.ProviderId
            });
        }
Beispiel #13
0
        private int IsSame()
        {
            Brand         brand    = new Brand();
            BrandProvider provider = new BrandProvider();

            brand.Brand_name = this.txt_name.Text;
            DataTable table = new DataTable();

            table = provider.Select(brand);
            if (table.Rows.Count != 0)
            {
                this.Alert("该品牌已经存在,请重新输入!!!");
                return(1);
            }
            else
            {
                return(0);
            }
        }
 /// <summary>
 ///  绑定Brand信息的数据源
 /// </summary>
 private void BindSource(int start, string name)
 {
     if (name != null)
     {
         Brand brand = new Brand();
         brand.Brand_name = name;
         BrandProvider provider = new BrandProvider();
         DataTable     table    = provider.Select(brand, start, this.ListPager1.PageSize);
         this.GridView1.DataSource = table.DefaultView;
         this.GridView1.DataBind();
     }
     else
     {
         BrandProvider provider = new BrandProvider();
         DataTable     table    = provider.GetAll(start, this.ListPager1.PageSize);
         this.GridView1.DataSource = table.DefaultView;
         this.GridView1.DataBind();
     }
 }
Beispiel #15
0
        private static ButtonModel CreateLaunchButton(Brand brand, BrandProvider provider)
        {
            string uri = MainWindow.IsUrlAsHttp(provider.Uri) == true
                ? provider.Uri
                    : Path.Combine(ResourceManager.Root, brand.NameAndFolder, provider.Uri);

            try
            {
                if (
                    ((MainWindow.IsUrlAsHttp(provider.Uri) == false) &&
                     (
                         (provider.Uri.IndexOf(@"\") >= 0)
                         & (provider.Uri.ToLower().IndexOf(".exe") >= 0)
                     )
                    ) &&
                    System.IO.File.Exists(provider.Uri) == true)
                {
                    uri = provider.Uri;
                }
                else
                {
                    ;
                }
            }
            catch
            {
            }

            return(new ButtonModel {
                Height = 40.0
                , HorizontalContentAlignment = HorizontalAlignment.Center
                , Margin = new Thickness(0.0, 0.0, 0.0, 0.0)
                , Content = provider.Title
                , DataContext = uri
                , Login = provider.Login
                , Password = provider.Password
                , ButtonStyle = brand.ButtonStyle
                , ProviderId = provider.ProviderId
            });
        }
Beispiel #16
0
        private void newBrowserLauncherView(Interop.SystemTime time, BrandProvider brandProvider)
        {
            Uri    uri;
            string urlSession = string.Empty;

            uri        = new Uri(brandProvider.Uri);
            urlSession = string.Format("{0}://{1}", uri.Scheme, uri.Host);

            if (_dictBrowserLauncherView.ContainsKey(brandProvider.ProviderId) == false)
            {
                _dictBrowserLauncherView.Add(brandProvider.ProviderId, new BrowserLauncherView(time
                                                                                               , brandProvider.Title
                                                                                               , brandProvider.Uri
                                                                                               , brandProvider.ProviderId
                                                                                               , brandProvider.Login
                                                                                               , brandProvider.Password));
                _dictBrowserLauncherView[brandProvider.ProviderId].Closing += new CancelEventHandler(closingViewer <BrowserLauncherView>);
                _dictBrowserLauncherView[brandProvider.ProviderId].Show();
            }
            else
            {
                _dictBrowserLauncherView[brandProvider.ProviderId].Activate();
            }
        }
Beispiel #17
0
        public LauncherSettings DownloadSettings(bool force, bool FullLoad = true)
        {
            string           path  = "launcherDBSettings.dat";
            LauncherSettings graph = new LauncherSettings();

            if (force && File.Exists(path))
            {
                File.Delete(path);
            }
            if (File.Exists(path))
            {
                Stream          stream    = File.OpenRead(path);
                BinaryFormatter formatter = new BinaryFormatter();
                graph = (LauncherSettings)formatter.Deserialize(stream);
                stream.Close();
                return(graph);
            }
            using (AvtoritetEntities entities = new AvtoritetEntities())
            {
                List <NewLauncher.DataContext.Brand> list = (from r in entities.Brand
                                                             where r.Enable
                                                             orderby r.NameAndFolder
                                                             select r).ToList <NewLauncher.DataContext.Brand>();
                List <Provider> list2 = (from r in entities.Provider
                                         where r.Enable & FullLoad
                                         orderby r.Order
                                         select r).ToList <Provider>();
                List <ProviderAccount> list3 = (from t in entities.ProviderAccount
                                                where t.Enable & FullLoad
                                                select t).ToList <ProviderAccount>();
                List <NewLauncher.DataContext.CommandFile> list4 = (from t in entities.CommandFile
                                                                    where FullLoad
                                                                    select t).ToList <NewLauncher.DataContext.CommandFile>();
                List <NewLauncher.DataContext.ProviderFile> list5 = (from t in entities.ProviderFile
                                                                     where FullLoad
                                                                     select t).ToList <NewLauncher.DataContext.ProviderFile>();
                List <Group> list6 = (from t in entities.Group
                                      where t.Enable
                                      orderby t.Order
                                      select t).ToList <Group>();
                List <NewLauncher.DataContext.GroupBox> list7 = (from r in entities.GroupBox
                                                                 where r.Enable
                                                                 orderby r.Title
                                                                 select r).ToList <NewLauncher.DataContext.GroupBox>();
                foreach (Group group in list6)
                {
                    GroupSet item = new GroupSet {
                        Name      = group.Name,
                        Width     = group.Width.Value,
                        Height    = group.Height.Value,
                        GroupBoxs = new List <CatalogApi.Settings.GroupBox>()
                    };
                    foreach (NewLauncher.DataContext.GroupBox box in list7)
                    {
                        if (box.GroupId == group.GroupId)
                        {
                            CatalogApi.Settings.GroupBox box2 = new CatalogApi.Settings.GroupBox {
                                Left          = box.Left.Value,
                                Top           = box.Top.Value,
                                Width         = box.Width.Value,
                                Height        = box.Height.Value,
                                Title         = box.Title,
                                VisibleBorder = box.VisibleBorder.Value,
                                Brands        = new List <CatalogApi.Settings.Brand>()
                            };
                            foreach (NewLauncher.DataContext.Brand brand in list)
                            {
                                if (brand.GroupBoxId == box.GroupBoxId)
                                {
                                    CatalogApi.Settings.Brand brand2 = new CatalogApi.Settings.Brand {
                                        NameAndFolder = brand.NameAndFolder,
                                        IconPath      = brand.IconPath,
                                        IconPath2     = brand.IconPath2,
                                        IconPathImg   = brand.IconPathImg,
                                        IconPath2Img  = brand.IconPath2Img
                                    };
                                    int?top = brand.Top;
                                    brand2.Top         = top.HasValue ? top.GetValueOrDefault() : 0;
                                    top                = brand.Left;
                                    brand2.Left        = top.HasValue ? top.GetValueOrDefault() : 0;
                                    top                = brand.Width;
                                    brand2.Width       = top.HasValue ? top.GetValueOrDefault() : 0;
                                    top                = brand.Height;
                                    brand2.Height      = top.HasValue ? top.GetValueOrDefault() : 0;
                                    brand2.BrandId     = brand.BrandId;
                                    brand2.ButtonStyle = brand.ButtonStyle;
                                    brand2.MenuWindow  = brand.MenuWindow.Value;
                                    brand2.Providers   = new List <BrandProvider>();
                                    foreach (Provider provider in list2)
                                    {
                                        int providerId;
                                        if (provider.BrandId != brand.BrandId)
                                        {
                                            continue;
                                        }
                                        BrandProvider provider2 = new BrandProvider {
                                            Uri        = provider.Uri.Trim(),
                                            IconPath   = provider.IconPath,
                                            Title      = provider.Title,
                                            Commands   = provider.commandcontent,
                                            ProviderId = provider.ProviderId,
                                            Login      = "",
                                            Password   = ""
                                        };
                                        foreach (ProviderAccount account in list3)
                                        {
                                            if (account.ProviderId == provider.ProviderId)
                                            {
                                                provider2.Login    = (account != null) ? account.Login.Trim() : string.Empty;
                                                provider2.Password = (account != null) ? account.Password.Trim() : string.Empty;
                                                break;
                                            }
                                        }
                                        provider2.CommandFiles = new List <CatalogApi.Settings.CommandFile>();
                                        foreach (NewLauncher.DataContext.CommandFile file in list4)
                                        {
                                            top        = file.ProviderId;
                                            providerId = provider.ProviderId;
                                            if ((top.GetValueOrDefault() == providerId) && top.HasValue)
                                            {
                                                CatalogApi.Settings.CommandFile file2 = new CatalogApi.Settings.CommandFile {
                                                    FileName    = file.FileName,
                                                    FileContent = file.FileContent
                                                };
                                                provider2.CommandFiles.Add(file2);
                                            }
                                        }
                                        provider2.ProviderFiles = new List <CatalogApi.Settings.ProviderFile>();
                                        foreach (NewLauncher.DataContext.ProviderFile file3 in list5)
                                        {
                                            top        = file3.ProviderId;
                                            providerId = provider.ProviderId;
                                            if ((top.GetValueOrDefault() == providerId) && top.HasValue)
                                            {
                                                CatalogApi.Settings.ProviderFile file4 = new CatalogApi.Settings.ProviderFile {
                                                    FileName    = file3.FileName,
                                                    FileExt     = file3.FileExt,
                                                    FileSize    = file3.FileSize.Value,
                                                    FileContent = file3.FileContent
                                                };
                                                provider2.ProviderFiles.Add(file4);
                                            }
                                        }
                                        brand2.Providers.Add(provider2);
                                    }
                                    box2.Brands.Add(brand2);
                                }
                            }
                            item.GroupBoxs.Add(box2);
                        }
                    }
                    graph.Groups.Add(item);
                }
            }
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            Stream serializationStream = File.Create(path);

            new BinaryFormatter().Serialize(serializationStream, graph);
            serializationStream.Close();
            if (force)
            {
                this.ExtractResourcesToFolder(graph);
            }
            return(graph);
        }
        private void ItemMaster_Load(object sender, EventArgs e)
        {
            this.UnitItems.Insert(0, new ComboBoxItem() { Text = "--Select Measure unit--", Value = "0" });
            comboBoxItemBindingSource.DataSource = this.UnitItems;

            BrandProvider brandProvider = new BrandProvider();
            VendorProvider vendorProvider = new VendorProvider();

            //Bind Dropdown controls
            var brands = brandProvider.GetAllForDropDown();
            brands.Insert(0, new ComboBoxItem() { Value = "0", Text = "--Select Brand--" });
            this.ddBrand.DataSource = brands;

            var vendors = vendorProvider.GetAllForDropDown();
            vendors.Insert(0, new ComboBoxItem() { Value = "0", Text = "--Select Vendor--" });
            this.ddPrefferedVendor.DataSource = vendors;

            BindItemsList();
            ddMeasureUnits.SelectedValue = "0";
            ddBrand.SelectedValue = "0";
            ddPrefferedVendor.SelectedValue = "0";
        }
Beispiel #19
0
        private void button_onClick(object sender, RoutedEventArgs e)
        {
            BrandProvider brandProvider = null;
            string        url           = string.Empty;

            try
            {
                brandProvider = (from item in this.brand.Providers
                                 where item.ProviderId == ((ButtonModel)sender).ProviderId
                                 select item).Cast <BrandProvider>()?.ElementAt(0);

                url =
                    brandProvider.Uri;

                if (url.StartsWith("http") || url.StartsWith("https"))
                {
                    if (url.Contains(ResourceManager.Urls[CatalogApi.UrlConstants.Key.ChevroletOpelGroupRoot]) == true)
                    {
                        string appKey = "ChevroletOpelGroupBrowser";

                        if (ConfigurationManager.AppSettings[appKey] == MODE_BROWSE.Separate.ToString())
                        {
                            // вариант №1(отдельный броаузер)
                            StartSeparateProcess(url, brandProvider.ProviderId);
                        }
                        else if (ConfigurationManager.AppSettings[appKey] == MODE_BROWSE.Common.ToString())
                        {
                            // вариант №2 (как у всех остальных Brand)
                            NewBrowserLauncherView(brandProvider);
                        }
                        else
                        {
                            ErrorLogHelper.AddErrorInLog("::button_onClick () - ...", string.Format("см. файл конфигурации key={0}", appKey));
                            MessageBox.Show(string.Format("Некорректные установки в файле конфигурации, key={0}", appKey));
                        }
                    }
                    else
                    {
                        NewBrowserLauncherView(brandProvider);
                    }
                }
                else
                {
                    url = MainWindow.GetPathBrandToProcess(url, brand.NameAndFolder);

                    using (Process process = new Process {
                        StartInfo =
                        {
                            UseShellExecute = false
                            , FileName      = url
                            , CreateNoWindow= true
                            , Verb          = url
                        }
                    }) {
                        process.Start();
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(string.Format("::button_onClick (url={1}, Commands={2}) - ...{0}Message={3}{0}StackTrace={4}"
                                              , Environment.NewLine
                                              , url, brandProvider == null ? "null" : brandProvider.Commands
                                              , exception.Message, exception.StackTrace));
                ErrorLogHelper.AddErrorInLog(string.Format("::button_onClick (url={0}, Commands={1}) - ..."
                                                           , url, brandProvider == null ? "null" : brandProvider.Commands)
                                             , string.Format("{0} | {1}", exception.Message, exception.StackTrace));

                //new ReportWindow().ShowReportWindow(exception);
            }
        }
Beispiel #20
0
        public BrandProviderTests()
        {
            Mock <IEntityFileProvider> entityFileProvider = new Mock <IEntityFileProvider>();

            provider = new BrandProvider(new NoDI_NHibernateContextFactory(), entityFileProvider.Object);
        }
Beispiel #21
0
 public BrandProviderTests()
 {
     Mock<IEntityFileProvider> entityFileProvider = new Mock<IEntityFileProvider>();
     provider = new BrandProvider(new NoDI_NHibernateContextFactory(), entityFileProvider.Object);
 }
Beispiel #22
0
        public LauncherSettings DownloadSettings(bool force, bool FullLoad = true)
        {
            string           nameFileDbSerialize = new CatalogApi.Settings.File(ConfigurationManager.AppSettings["FileDbSerialize"]).Name;
            LauncherSettings graph = new LauncherSettings();

            // режим "force" принажатии кнопки брэнда
            if ((force == true) &&
                (System.IO.File.Exists(nameFileDbSerialize) == true))
            {
                System.IO.File.Delete(nameFileDbSerialize);
            }
            else
            {
                ;
            }

            if (System.IO.File.Exists(nameFileDbSerialize) == true)
            {
                // для режима forse=false - прочитать и вернуть копию БД
                Stream          stream    = System.IO.File.OpenRead(nameFileDbSerialize);
                BinaryFormatter formatter = new BinaryFormatter();
                graph = (LauncherSettings)formatter.Deserialize(stream);
                stream.Close();

                return(graph);
            }
            else
            {
                ;
            }

            #region чтение БД, заполнение объектов значениями
            using (AvtoritetEntities entities = new AvtoritetEntities())
            {
                List <NewLauncher.DataContext.Brand> list = (from r in entities.Brand
                                                             where r.Enable
                                                             orderby r.NameAndFolder
                                                             select r).ToList <NewLauncher.DataContext.Brand>();
                List <Provider> list2 = (from r in entities.Provider
                                         where r.Enable & FullLoad
                                         orderby r.Order
                                         select r).ToList <Provider>();
                List <ProviderAccount> list3 = (from t in entities.ProviderAccount
                                                where t.Enable & FullLoad
                                                select t).ToList <ProviderAccount>();
                List <NewLauncher.DataContext.CommandFile> list4 = (from t in entities.CommandFile
                                                                    where FullLoad
                                                                    select t).ToList <NewLauncher.DataContext.CommandFile>();
                List <NewLauncher.DataContext.ProviderFile> list5 = (from t in entities.ProviderFile
                                                                     where FullLoad
                                                                     select t).ToList <NewLauncher.DataContext.ProviderFile>();
                List <Group> list6 = (from t in entities.Group
                                      where t.Enable
                                      orderby t.Order
                                      select t).ToList <Group>();
                List <NewLauncher.DataContext.GroupBox> list7 = (from r in entities.GroupBox
                                                                 where r.Enable
                                                                 orderby r.Title
                                                                 select r).ToList <NewLauncher.DataContext.GroupBox>();
                foreach (Group group in list6)
                {
                    GroupSet item = new GroupSet {
                        Name      = group.Name,
                        Width     = group.Width.Value,
                        Height    = group.Height.Value,
                        GroupBoxs = new List <CatalogApi.Settings.GroupBox>()
                    };
                    foreach (NewLauncher.DataContext.GroupBox box in list7)
                    {
                        if (box.GroupId == group.GroupId)
                        {
                            CatalogApi.Settings.GroupBox box2 = new CatalogApi.Settings.GroupBox {
                                Left          = box.Left.Value,
                                Top           = box.Top.Value,
                                Width         = box.Width.Value,
                                Height        = box.Height.Value,
                                Title         = box.Title,
                                VisibleBorder = box.VisibleBorder.Value,
                                Brands        = new List <CatalogApi.Settings.Brand>()
                            };
                            foreach (NewLauncher.DataContext.Brand brand in list)
                            {
                                if (brand.GroupBoxId == box.GroupBoxId)
                                {
                                    CatalogApi.Settings.Brand brand2 = new CatalogApi.Settings.Brand {
                                        NameAndFolder = brand.NameAndFolder,
                                        IconPath      = brand.IconPath,
                                        IconPath2     = brand.IconPath2,
                                        IconPathImg   = brand.IconPathImg,
                                        IconPath2Img  = brand.IconPath2Img
                                    };
                                    int?top = brand.Top;
                                    brand2.Top         = top.HasValue ? top.GetValueOrDefault() : 0;
                                    top                = brand.Left;
                                    brand2.Left        = top.HasValue ? top.GetValueOrDefault() : 0;
                                    top                = brand.Width;
                                    brand2.Width       = top.HasValue ? top.GetValueOrDefault() : 0;
                                    top                = brand.Height;
                                    brand2.Height      = top.HasValue ? top.GetValueOrDefault() : 0;
                                    brand2.BrandId     = brand.BrandId;
                                    brand2.ButtonStyle = brand.ButtonStyle;
                                    brand2.MenuWindow  = brand.MenuWindow.Value;
                                    brand2.Providers   = new List <BrandProvider>();
                                    foreach (Provider provider in list2)
                                    {
                                        int providerId;
                                        if (provider.BrandId != brand.BrandId)
                                        {
                                            continue;
                                        }
                                        BrandProvider provider2 = new BrandProvider {
                                            Uri        = provider.Uri.Trim(),
                                            IconPath   = provider.IconPath,
                                            Title      = provider.Title,
                                            Commands   = provider.commandcontent,
                                            ProviderId = provider.ProviderId,
                                            Login      = "",
                                            Password   = ""
                                        };
                                        foreach (ProviderAccount account in list3)
                                        {
                                            if (account.ProviderId == provider.ProviderId)
                                            {
                                                provider2.Login    = (account != null) ? account.Login.Trim() : string.Empty;
                                                provider2.Password = (account != null) ? account.Password.Trim() : string.Empty;
                                                break;
                                            }
                                        }
                                        provider2.CommandFiles = new List <CatalogApi.Settings.CommandFile>();
                                        foreach (NewLauncher.DataContext.CommandFile file in list4)
                                        {
                                            top        = file.ProviderId;
                                            providerId = provider.ProviderId;
                                            if ((top.GetValueOrDefault() == providerId) && top.HasValue)
                                            {
                                                CatalogApi.Settings.CommandFile file2 = new CatalogApi.Settings.CommandFile {
                                                    FileName    = file.FileName,
                                                    FileContent = file.FileContent
                                                };
                                                provider2.CommandFiles.Add(file2);
                                            }
                                        }
                                        provider2.ProviderFiles = new List <CatalogApi.Settings.ProviderFile>();
                                        foreach (NewLauncher.DataContext.ProviderFile file3 in list5)
                                        {
                                            top        = file3.ProviderId;
                                            providerId = provider.ProviderId;
                                            if ((top.GetValueOrDefault() == providerId) && top.HasValue)
                                            {
                                                CatalogApi.Settings.ProviderFile file4 = new CatalogApi.Settings.ProviderFile {
                                                    FileName    = file3.FileName,
                                                    FileExt     = file3.FileExt,
                                                    FileSize    = file3.FileSize.Value,
                                                    FileContent = file3.FileContent
                                                };
                                                provider2.ProviderFiles.Add(file4);
                                            }
                                        }
                                        brand2.Providers.Add(provider2);
                                    }
                                    box2.Brands.Add(brand2);
                                }
                            }
                            item.GroupBoxs.Add(box2);
                        }
                    }
                    graph.Groups.Add(item);
                }
            }
            #endregion

            if (System.IO.File.Exists(nameFileDbSerialize) == true)
            {
                //??? никогда не выполняется
                // , если forse=true файл будет удален
                // , если forse=false произодет возврат значения и выход из функции
                System.IO.File.Delete(nameFileDbSerialize);
            }
            else
            {
                ;
            }

            Stream serializationStream = System.IO.File.Create(nameFileDbSerialize);
            new BinaryFormatter().Serialize(serializationStream, graph);
            serializationStream.Close();

            if (force == true)
            {
                this.ExtractResourcesToFolder(graph);
            }
            else
            {
                ;
            }

            return(graph);
        }
Beispiel #23
0
        private void showBrowserLauncherView(Interop.SystemTime time, BrandProvider brandProvider)
        {
            Uri    uri;
            string urlSession = string.Empty;
            KeyBrowserLauncherView keyView;
            IOrderedEnumerable <KeyBrowserLauncherView> keys;
            MessageBoxResult res;
            int iMaxCountLauncherOnProvider = 1;

            uri        = new Uri(brandProvider.Uri);
            urlSession = string.Format("{0}://{1}", uri.Scheme, uri.Host);

            int.TryParse(ConfigurationManager.AppSettings["MaxCountLauncherOnProvider"], out iMaxCountLauncherOnProvider);
            keys = _dictBrowserLauncherView.Keys.Where(key => { return(key.ProviderId == brandProvider.ProviderId); })
                   .OrderBy(key => key.StampDateTime);

            if ((keys.Count() == 0) ||
                (keys.Count() < iMaxCountLauncherOnProvider))
            {
                if (keys.Count() > 0)
                {
                    res = MessageBox.Show(string.Format("Каталог этого провайдера уже отображается ({1} шт.).{0}Открыть новый каталог ({2})?{0}Установить фокус ввода на открытый ранее({3})?{0}Отменить операцию({4})?"
                                                        , Environment.NewLine
                                                        , keys.Count()
                                                        , MessageBoxResult.Yes, MessageBoxResult.No, MessageBoxResult.Cancel)
                                          , "Внимание!"
                                          , MessageBoxButton.YesNoCancel);
                }
                else
                {
                    res = MessageBoxResult.Yes;
                }

                if (res == MessageBoxResult.Yes)
                {
                    keyView = new KeyBrowserLauncherView()
                    {
                        ProviderId      = brandProvider.ProviderId
                        , StampDateTime =
                            //new DateTime(
                            //    time.Year, time.Month, time.Day
                            //    , time.Hour, time.Minute, time.Second, time.Millisecond
                            //    , DateTimeKind.Local
                            //)
                            DateTime.Now
                    };

                    _dictBrowserLauncherView.Add(keyView
                                                 , new BrowserLauncherView(time
                                                                           , brandProvider.Title
                                                                           , brandProvider.Uri
                                                                           , brandProvider.ProviderId
                                                                           , brandProvider.Login
                                                                           , brandProvider.Password));
                    _dictBrowserLauncherView[keyView].Closing += new CancelEventHandler(closingViewer <BrowserLauncherView>);
                    _dictBrowserLauncherView[keyView].Show();
                }
                else if (res == MessageBoxResult.No)
                {
                    keyView = keys.ElementAt(0);
                    _dictBrowserLauncherView[keyView].Activate();
                }
                else
                {
                    ;
                }
            }
            else
            {
                keyView = keys.ElementAt(0);
                _dictBrowserLauncherView[keyView].Activate();
            }
        }