Beispiel #1
0
        private bool Validate(PackModel packModel)
        {
            if (!packModel.Files.Any())
            {
                this.ModelState.AddModelError("Błąd", "Pole [SVN Files] - uzupełnij pliki do paczki");
            }

            foreach (var file in packModel.Files)
            {
                if (!Regex.IsMatch(file, "http://.*"))
                {
                    this.ModelState.AddModelError("Błąd", "Pole [SVN Files] - podaj prawidłowy link do pliku");
                }
            }

            if (string.IsNullOrEmpty(packModel.Component))
            {
                this.ModelState.AddModelError("Błąd", "Pole [Component] - uzupełnij komponent");
            }

            if (string.IsNullOrEmpty(packModel.ProjectId))
            {
                this.ModelState.AddModelError("Błąd", "Pole [Projects] - uzupełnij projekty");
            }

            if (string.IsNullOrEmpty(packModel.TestEnvironment))
            {
                this.ModelState.AddModelError("Błąd", "Pole [Environment] - uzupełnij środowisko");
            }

            return(!this.ModelState.IsValid);
        }
Beispiel #2
0
        public ActionResult CreateIvec(PackModel packModel)
        {
            this.FillPackModel(packModel);

            if (Validate(packModel))
            {
                return(View("Create", packModel));
            }

            var packFile = this.PackApi.CreatePackFile(packModel);

            using (var client = new WebClient())
            {
#if DEBUG
                client.Credentials = new NetworkCredential(packModel.UserSkp.Substring(9), "AP6sYG9ktmWsTVcSp5roxfFytckrqyFXvxx6hN");
#else
                client.Credentials = new NetworkCredential(packModel.UserSkp.Substring(9), packModel.UserApiKey);
#endif
                var resultByte = client.UploadFile(new Uri($"{SERVERURL}{packFile.Name}"), "PUT", packFile.FullName);

                var model = new PackModel
                {
                    SendModel = new SendModel
                    {
                        Result = Infrastructure.Helper.FormatJson(Encoding.UTF8.GetString(resultByte))
                    }
                };

                this.FillPackModel(model);

                return(View("Create", model));
            }
        }
        private void ShowAddPackDialog()
        {
            PackModel packModel = _dialogService.ShowAddPackDialog();

            if (packModel != null)
            {
                foreach (string item in packModel.Items)
                {
                    string   itemName = String.Empty;
                    int      quantity = 0;
                    string[] parts    = item.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length == 2)
                    {
                        itemName = parts[0];
                        if (Int32.TryParse(parts[1], out int number))
                        {
                            quantity = number;
                        }
                    }
                    else
                    {
                        itemName = item;
                        quantity = 1;
                    }

                    if (!String.IsNullOrWhiteSpace(itemName))
                    {
                        EquipmentModel equipmentModel = new EquipmentModel();
                        ItemModel      itemModel      = _compendium.Items.FirstOrDefault(x => x.Name.Equals(itemName, StringComparison.CurrentCultureIgnoreCase));

                        if (itemModel != null)
                        {
                            equipmentModel.Item = itemModel;
                            equipmentModel.Name = itemModel.Name;
                        }
                        else
                        {
                            equipmentModel.Name = itemName;
                        }

                        equipmentModel.Quantity = quantity;

                        EquipmentViewModel equipmentViewModel = new EquipmentViewModel(equipmentModel);
                        equipmentViewModel.PropertyChanged += EquipmentViewModel_PropertyChanged;

                        _equipment.Add(equipmentViewModel);
                        _bagModel.Equipment.Add(equipmentModel);
                    }
                }

                _equipment = new ObservableCollection <EquipmentViewModel>(_equipment.OrderBy(x => x.Name));

                OnPropertyChanged(nameof(Equipment));
                OnPropertyChanged(nameof(ShowEquipmentHeader));
                UpdateTotalWeight();
            }
        }
        /// <summary>
        /// Initializes pack options
        /// </summary>
        public void InitializePackOptions()
        {
            _packOptions.Clear();
            foreach (PackModel packModel in _compendium.Packs)
            {
                _packOptions.Add(new KeyValuePair <PackModel, string>(packModel, packModel.Name));
            }

            _selectedPackOption = _packOptions[0];
            _packModel          = _selectedPackOption.Key;
        }
Beispiel #5
0
 public void AddPackToHistory(PackModel packModel)
 {
     this.PrimeEwsiDbApi.AddHistoryPack(new HistoryPackModel
     {
         Component   = packModel.Component,
         Environment = packModel.TestEnvironment,
         Files       = string.Join("|", packModel.Files),
         Projects    = packModel.ProjectId,
         Teets       = packModel.Teets,
         UserId      = packModel.UserId
     });
 }
Beispiel #6
0
        private string CreateDirectory(PackModel packModel)
        {
            var pathToFolderWithUserPack = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~"), "Pack", packModel.UserName, packModel.Component);

            if (Directory.Exists(pathToFolderWithUserPack))
            {
                Directory.Delete(pathToFolderWithUserPack, true);
            }

            Directory.CreateDirectory(pathToFolderWithUserPack);

            return(pathToFolderWithUserPack);
        }
Beispiel #7
0
        private void FillPackModel(PackModel packModel)
        {
            packModel.SetUser(Infrastructure.Helper.GetUserModel());

            packModel.HistoryPackCollection = this.PrimeEwsiDbApi.GetHistoryPacksByUserId(packModel.UserId);

            packModel.JiraTeets = this.JiraApi.GetJiraTets(packModel.UserJiraCookie);

            packModel.JiraComponents = this.JiraApi.GetComponents(packModel.UserJiraCookie);

            packModel.JiraEnvironment = this.JiraApi.GetEnvironment(packModel.UserJiraCookie);

            packModel.JiraProject = this.JiraApi.GetProjects(packModel.UserJiraCookie);
        }
Beispiel #8
0
        public FileInfo CreatePackFile(PackModel packModel)
        {
            var dir = CreateDirectory(packModel);

            var listOfLies = this.GetFileForSVN(packModel, dir).ToList();

            var dc = new DeploymentPackageDeploymentComponent
            {
                Name    = packModel.Component,
                Version = new DeploymentPackageDeploymentComponentVersion
                {
                    Name     = this.PrimeEwsiDbApi.GetConfigModelByComponent(packModel.Component).Version,
                    Type     = "Incremental",
                    Property = (new List <DeploymentPackageDeploymentComponentProperty>()).ToArray(),
                    FileList = listOfLies.Select(d => d.Name).ToArray()
                }
            };


            Helper.Manifestfilename = Path.Combine(dir, "metafile.xml");

            var xmlFile = Helper.SaveXml(new DeploymentPackage
            {
                provider        = "BZWBK",
                system          = "PRIME",
                TestEnvironment = packModel.TestEnvironment,
                IchangeProjects = new List <string> {
                    packModel.ProjectId
                }.ToArray(),
                ResolvedIssues      = packModel.Teets?.Split(',').Select(s => s.Trim()).ToArray(),
                DeploymentComponent = new DeploymentPackageDeploymentComponent[1] {
                    dc
                }
            });

            listOfLies.Add(xmlFile);

            var zipFileInfo =
                new FileInfo(Path.Combine(dir, $"{packModel.Component}-{DateTime.Now.ToString("dd-MM-yyyy-HH-mm-ss", CultureInfo.InvariantCulture)}.zip"));

            Helper.CreateZipFile(listOfLies, zipFileInfo.FullName);


            this.UpdateVersion(packModel.Component);

            AddPackToHistory(packModel);

            return(zipFileInfo);
        }
Beispiel #9
0
        private PackModel GetPackModel(int packId)
        {
            var pack = this.PrimeEwsiDbApi.GetHistoryPacksByPackId(packId);

            var packModel = new PackModel
            {
                Component       = pack.Component,
                ProjectId       = pack.Projects,
                Teets           = pack.Teets,
                TestEnvironment = pack.Environment,
                Files           = pack.Files.Split('|').ToList(),
            };

            return(packModel);
        }
Beispiel #10
0
        public ActionResult Create()
        {
            var userModel = Infrastructure.Helper.GetUserModel();

            if (userModel == null)
            {
                return(RedirectToAction("New", "Register"));
            }

            var model = new PackModel();

            this.FillPackModel(model);

            return(View(model));
        }
Beispiel #11
0
        protected override void OnLoad(EventArgs e)
        {
            //初始化标签打印模块
            string config = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\label.xml";

            if (!LabelPrintGlobal.g_LabelCreator.LoadConfig(config))
            {
                MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("LABEL_PRINT_INIT_ERROR"), "ERROR", MessageBoxButtons.OK);
                Close();
                return;
            }

            //基础配置文件
            LabelPrintGlobal.g_ConfigFile = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\config.xml";
            TPCResult <bool> rt = LabelPrintGlobal.g_Config.LoadConfig(LabelPrintGlobal.g_ConfigFile);

            if (rt.State == RESULT_STATE.NG)
            {
                MessageBox.Show(rt.Message);
                Close();
                return;
            }

            ///初始化三种模式
            #region 初始化三种模式
            m_Pack   = new PackModel(m_PackingForm);
            m_Carton = new CartonModel(m_PackingForm);
            m_Pallet = new PalletModel(m_PackingForm);

            m_Pack.Database   = m_DatabseHelper;
            m_Carton.Database = m_DatabseHelper;
            m_Pallet.Database = m_DatabseHelper;

            m_Pack.CodeKey   = "BM004HK1-1";
            m_Carton.CodeKey = "BM004HK1-1";
            m_Pallet.CodeKey = "BM004HK1-1";
            #endregion

            m_PackingForm.Model = m_Pack;

            m_PackingForm.Show();
            InitLanguage();
            InitAuth();

            ShowMode(PACK_MODE.Pack);
        }
Beispiel #12
0
        private IEnumerable <FileInfo> GetFileForSVN(PackModel packModel, string dirPath)
        {
            var svnUrls =
                packModel.Files.ToArray().Select(d => new SqlFile
            {
                Name = d.Substring(d.LastIndexOf("/") + 1),
                URL  = d
            });

            var nc = new NetworkCredential
            {
                UserName = packModel.SvnUser,
                Password = packModel.SvnPassword
            };

            return(svnUrls.Select(svnUrl => Helper.DownloadFileUsingSvnCheckout(svnUrl, nc, dirPath)));
        }
Beispiel #13
0
        private void PopulatePacks()
        {
            PackModel burglarPack = new PackModel();

            burglarPack.Name  = "Burglar's Pack";
            burglarPack.Items = new List <string>(new string[] { "Backpack", "Ball Bearings", "String (10 feet)", "Bell", "Candle:5", "Crowbar", "Hammer", "Piton:10",
                                                                 "Hooded Lantern", "Oil (flask):2", "Rations (1 day):5", "Tinderbox", "Waterskin", "Hempen Rope (50 feet)" });
            _packs.Add(burglarPack);

            PackModel diplomatPack = new PackModel();

            diplomatPack.Name  = "Diplomat's Pack";
            diplomatPack.Items = new List <string>(new string[] { "Chest", "Map or Scroll Case:2", "Fine Clothes", "Ink (1 ounce bottle)", "Ink Pen", "Lamp",
                                                                  "Oil (flask):2", "Paper (one sheet):5", "Perfume (vial)", "Sealing Wax", "Soap" });
            _packs.Add(diplomatPack);

            PackModel dungeoneerPack = new PackModel();

            dungeoneerPack.Name  = "Dungeoneer's Pack";
            dungeoneerPack.Items = new List <string>(new string[] { "Backpack", "Crowbar", "Hammer", "Piton:10", "Torch:10", "Tinderbox", "Rations (1 day):10", "Waterskin", "Hempen Rope (50 feet)" });
            _packs.Add(dungeoneerPack);

            PackModel entertainerPack = new PackModel();

            entertainerPack.Name  = "Entertainer's Pack";
            entertainerPack.Items = new List <string>(new string[] { "Backpack", "Bedroll", "Costume Clothes:2", "Candle:5", "Rations (1 day):5", "Waterskin", "Disguise Kit" });
            _packs.Add(entertainerPack);

            PackModel explorerPack = new PackModel();

            explorerPack.Name  = "Explorer's Pack";
            explorerPack.Items = new List <string>(new string[] { "Backpack", "Bedroll", "Mess Kit", "Tinderbox", "Torch:10", "Rations (1 day):10", "Waterskin", "Hempen Rope (50 feet)" });
            _packs.Add(explorerPack);

            PackModel priestPack = new PackModel();

            priestPack.Name  = "Priest's Pack";
            priestPack.Items = new List <string>(new string[] { "Backpack", "Blanket", "Candle:10", "Tinderbox", "Alms Box", "Block of Incense:2", "Censer", "Vestments", "Rations (1 day):2", "Waterskin" });
            _packs.Add(priestPack);

            PackModel scholarPack = new PackModel();

            scholarPack.Name  = "Scholar's Pack";
            scholarPack.Items = new List <string>(new string[] { "Backpack", "Book", "Ink (1 ounce bottle)", "Ink Pen", "Parchment (one sheet):10", "Little Bag of Sand", "Small Knife" });
            _packs.Add(scholarPack);
        }
Beispiel #14
0
        public ActionResult Download(PackModel packModel)
        {
            this.FillPackModel(packModel);

            if (Validate(packModel))
            {
                return(View("Create", packModel));
            }

            var zipFileInfo = this.PackApi.CreatePackFile(packModel);

            var contentDisposition = new ContentDisposition
            {
                FileName = zipFileInfo.Name,
                Inline   = false,
            };

            Response.AppendHeader("Content-Disposition", contentDisposition.ToString());

            return(File(System.IO.File.ReadAllBytes(zipFileInfo.FullName), MimeMapping.GetMimeMapping(zipFileInfo.Name)));
        }
 /// <summary>
 /// Creates an instance of <see cref="PackViewModel"/>
 /// </summary>
 public PackViewModel(PackModel packModel)
 {
     _packModel = packModel;
 }
Beispiel #16
0
        public static object GetPacks(Configuration configuration, DataSource dataSource)
        {
            var           source     = dataSource.GetDataSource <NdfBinary>(configuration.DataMappings["DeckData"]);
            List <object> outputData = new List <object>();
            var           output     = new ExportedDataTable()
            {
                MetaData = new ExportedDataTable.MetaDataModel()
                {
                    DataIdentifier = "Packs",
                    ExtractedFrom  = new[]
                    {
                        configuration.DataMappings["DeckData"],
                        configuration.DataMappings["LocalizationOutgame"]
                    }
                },
                Data = outputData
            };

            var serializer = source.Classes.First(x => x.Name == "TDeckSerializer");
            var instance   = serializer.Instances.First();
            var packMap    = instance.PropertyValues.First(x => x.Property.Name == "PackIds").Value as NdfMapList;

            for (var i = 0; i < packMap.Count; i++)
            {
                var pack = new PackModel();
                outputData.Add(pack);

                var kvMap = packMap[i].Value as NdfMap;
                pack.Id = (int)(UInt32)((kvMap.Value as MapValueHolder).Value as NdfUInt32).Value;

                var mapValue = kvMap.Key as MapValueHolder;
                var packRef  = mapValue.Value as NdfObjectReference;
                var packInst = packRef.Instance;

                pack.FactoryType        = (int)packInst.GetInstancePropertyValue <int>("FactoryType");
                pack.ExperienceLevel    = (int)packInst.GetInstancePropertyValue <int>("ExperienceLevel");
                pack.AvailableFromPhase = (int)(UInt32)packInst.GetInstancePropertyValue <UInt32>("AvailableFromPhase");

                var tpUnitList = packInst.PropertyValues.FirstOrDefault(x => x.Property.Name == "TransporterAndUnitsList")?.Value as
                                 NdfCollection;

                if (tpUnitList != null)
                {
                    pack.TransportAndUnitCount = tpUnitList.Count;

                    var tpAndUnitsDescriptorRef = tpUnitList.FirstOrDefault()?.Value as NdfObjectReference;
                    var inst = tpAndUnitsDescriptorRef?.Instance;
                    if (inst != null)
                    {
                        var tpRef = inst.PropertyValues.FirstOrDefault(x => x.Property.Name == "TransporterDescriptor")?.Value as
                                    NdfObjectReference;
                        var tpInst = tpRef?.Instance;
                        if (tpInst != null)
                        {
                            pack.TransportDescriptorId =
                                (tpInst.PropertyValues.FirstOrDefault(x => x.Property.Name == "DescriptorId")?.Value as
                                 NdfGuid)?.Value.ToString();
                        }

                        var unitList = inst.PropertyValues.FirstOrDefault(x => x.Property.Name == "UnitDescriptorList")?.Value as NdfCollection;
                        var unitRef  = unitList?.FirstOrDefault()?.Value as NdfObjectReference;
                        var unitInst = unitRef?.Instance;
                        if (unitInst != null)
                        {
                            pack.UnitDescriptorId =
                                (unitInst.PropertyValues.FirstOrDefault(x => x.Property.Name == "DescriptorId")?.Value
                                 as NdfGuid)?.Value.ToString();
                        }
                    }
                }
            }

            return(output);
        }