예제 #1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            try
            {
                var url  = "&mac=" + (new SystemInfo().MacAddress);
                var list = Getway.LoadPcInfo(url);

                if (list.Count > 0)
                {
                    Tracer.Append($"Информация получена. Всего {list.Count} записей.");
                    var pcInfo = list?.First() ?? null;
                    if (pcInfo != null)
                    {
                        if (pcInfo.status == "IS_APPLY")
                        {
                            Getway.Log(pcInfo); //Данные по компьютеру уже приняты
                            Tracer.Append($"Данные по компьютеру уже приняты");
                            Current.Shutdown(); // Проигнорировать и отправить SystemInfo
                        }
                        else if (pcInfo.status == "PROCESSING")
                        {
                            Getway.Log(pcInfo);
                            if (MessageBox.Show("Данные по вашему компьютеру находятся на обработке.\nВы хотите отредактировать какие либо значения?", "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                            {
                                ShowView(pcInfo);                    // данные есть, но статус не подтвержден
                                ARMInfo.MainWindow.MayIGoOut = true; // сделать загрузку данных. (заполнение интерфейса)
                            }
                            else
                            {
                                Current.Shutdown();
                            }
                        }
                        else
                        {
                            ShowView();
                        }
                    }
                    else
                    {
                        ShowView();// нет никаких данных о компе
                    }
                }
                else
                {
                    Tracer.Append($"Нет данных о компьютере. Открываю интерфейс пользователя.");
                    var newPc = new PCInfo();
                    newPc.SetUp(new SystemInfo(), new PersonalInfo());
                    Getway.Log(newPc);
                    ShowView(); // нет никаких данных о компе
                }
            }
            catch (Exception err)
            {
                ARMInfo.MainWindow.MayIGoOut = true;
                MessageBox.Show(err.Message, "", MessageBoxButton.OK, MessageBoxImage.Error);

                Tracer.Append(err.Message);
                Current.Shutdown();
            }
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            PCInfo pCInfo = db.PCInfos.Find(id);

            db.PCInfos.Remove(pCInfo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
 public ActionResult Edit([Bind(Include = "ID,SerialNumber,IPAddress,UseSegment,MachineType,ModelNumber,UserName,PCName,Remark")] PCInfo pCInfo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pCInfo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pCInfo));
 }
예제 #4
0
        static void Main(string[] args)
        {
            WmiObjectFactory factory = new WmiObjectFactory("cache.db");
            PCInfo           info    = factory.Create <PCInfo>();

            Console.WriteLine("Processor type:\t\t{0}", info.ProcessorName);
            Console.WriteLine("BIOS Manufactorer:\t{0}", info.BIOSManufacturer);
            Console.WriteLine("Chip architecture:\t{0}", info.Architecture);
            Console.ReadLine();
        }
예제 #5
0
        protected NetworkData GetNetworkData(List <PCInfo> pcList)
        {
            var currentPC  = default(PCInfo);
            var currentIPs = Tool.GetLocalIPAddress();

            foreach (var ip in currentIPs)
            {
                var pcData = pcList.FindAll(pc => pc.ipAddress == ip);
                if (pcData != null && pcData.Count > 0)
                {
                    var first = pcData[0];
                    if (pcData.Count > 1)
                    {
                        Debug.LogWarningFormat("Multiple pc ip found, using the first one({0}) for networking", first.name);
                    }

                    currentPC = first;
                    break;
                }
            }
            var serverData = pcList.FindAll(pc => pc.role == PCInfo.Role.Server);

            if (currentPC == null)
            {
                LogTool.Log("Current pc not found, use current ip " + currentIPs[0], LogLevel.Warning);
                currentPC           = new PCInfo();
                currentPC.ipAddress = currentIPs[0];
                currentPC.role      = PCInfo.Role.None;
            }
            if (serverData == null)
            {
                LogTool.Log("serverData not found, add a default one", LogLevel.Warning);
                serverData = new List <PCInfo>()
                {
                    new PCInfo()
                    {
                        role = PCInfo.Role.Server
                    }
                };
            }
            LogTool.LogFormat("setup current pc ip {1} as {0}", LogLevel.Info, LogChannel.Debug | LogChannel.Network, currentPC.role.ToString(), currentPC.ipAddress);

            var clientData = pcList.FindAll(pc => pc.role == PCInfo.Role.Client && currentIPs.Contains(pc.ipAddress) == false);
            var devData    = pcList.FindAll(pc => pc.role == PCInfo.Role.Development);

            var data = new NetworkData()
            {
                current = currentPC,
                servers = serverData,
                devPCs  = devData,
                client  = new List <PCInfo>(clientData)
            };

            return(data);
        }
예제 #6
0
        public ActionResult Create([Bind(Include = "ID,SerialNumber,IPAddress,UseSegment,MachineType,ModelNumber,UserName,PCName,Remark")] PCInfo pCInfo)
        {
            if (ModelState.IsValid)
            {
                db.PCInfos.Add(pCInfo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pCInfo));
        }
예제 #7
0
        // GET: PCInfoes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PCInfo pCInfo = db.PCInfos.Find(id);

            if (pCInfo == null)
            {
                return(HttpNotFound());
            }
            return(View(pCInfo));
        }
예제 #8
0
    private void ScriptCharcterLookDB(eActorEditorType actorEditorType)
    {
        m_actorInfoList.Clear();

        ResData       resData       = DataManager.Instance.GetScriptData <ResData>();
        CharacterData characterData = DataManager.Instance.GetScriptData <CharacterData>();

        if (actorEditorType == eActorEditorType.Character)
        {
            if (resData != null)
            {
                List <DB_SpriteData> lstDatas = resData.GetCharacterSpriteList();
                foreach (DB_SpriteData spriteData in lstDatas)
                {
                    if (spriteData.objType == E_ObjectType.Pc)
                    {
                        string          Name            = string.Format("{0}_{1}", spriteData.id, spriteData.assetName);
                        EntityAssetInfo entityAssetInfo = new EntityAssetInfo(IDFactory.GenerateActorID(), eLayerMask.Actor, spriteData.spriteName, spriteData.spriteName);

                        PCInfo pcInfo = new PCInfo(eCombatType.PC, entityAssetInfo, Name, entityAssetInfo.ID, null);
                        m_actorInfoList.Add(pcInfo);
                    }
                }
            }
        }
        if (actorEditorType == eActorEditorType.Monster)
        {
            if (resData != null)
            {
                List <DB_SpriteData> lstDatas = resData.GetCharacterSpriteList();
                foreach (DB_SpriteData spriteData in lstDatas)
                {
                    if (spriteData.objType == E_ObjectType.Monster)
                    {
                        string          name            = string.Format("{0}_{1}", spriteData.id, spriteData.assetName);
                        EntityAssetInfo entityAssetInfo = new EntityAssetInfo(IDFactory.GenerateActorID(), eLayerMask.Actor, spriteData.spriteName, spriteData.spriteName);

                        MonsterInfo monsterInfo = new MonsterInfo(eCombatType.Monster, entityAssetInfo, name, entityAssetInfo.ID, null);
                        m_actorInfoList.Add(monsterInfo);
                    }
                }
            }
        }
    }
        public HttpResponseMessage Post([FromBody] PCInfo info)
        {
            var userNames   = info.Users.Select(x => x.Name);
            var commonUsers = _userRepository.GetAllAsQueryable().Where(x => userNames.Contains(x.Name)).ToList();

            info.Users = info.Users.Except(commonUsers, new UserNameEqualityComparer()).ToList();

            var new_info = _infoRepository.GetSingle(x => x.RamLoad == info.RamLoad && x.CpuLoad == info.CpuLoad);

            if (new_info != null)
            {
                new_info.DateTime = DateTime.Now;
            }

            var infoId = _infoRepository.AddOrUpdate(new_info ?? info);

            if (commonUsers.Any())
            {
                commonUsers.ForEach(x => x.PCInfoId = infoId);
                commonUsers.ForEach(x => _userRepository.Update(x));
            }

            return(Request.CreateResponse(HttpStatusCode.Created));
        }
예제 #10
0
        public static PCInfo[] GetPCInfoList(string userid)
        {
            PCInfo[] result = new PCInfo[3];

            // build query string
            string cmdstr = String.Format(@"SELECT SLOT1, SLOT2, SLOT3 FROM Player WHERE UserID = '{0}'", userid);

            // execute query
            MySqlCommand    cmd        = new MySqlCommand(cmdstr, mysqlconn);
            MySqlDataReader datareader = cmd.ExecuteReader();

            // read data
            if (datareader.HasRows)
            {
                datareader.Read();


                string name1 = null;
                string name2 = null;
                string name3 = null;

                if (!datareader.IsDBNull(0))
                {
                    name1 = datareader.GetString(0);
                }
                if (!datareader.IsDBNull(1))
                {
                    name2 = datareader.GetString(1);
                }
                if (!datareader.IsDBNull(2))
                {
                    name3 = datareader.GetString(2);
                }

                datareader.Close();

                if (name1 != null)
                {
                    PCType pctype = GetPCType(name1);
                    if (pctype == PCType.SLAYER)
                    {
                        PCSlayerInfo pc = GetPCSlayerInfo(name1);
                        pc.Slot = Slot.SLOT1;

                        result[0] = pc;
                    }
                    else if (pctype == PCType.VAMPIRE)
                    {
                        PCVampireInfo pc = GetPCVampireInfo(name1);
                        pc.Slot = Slot.SLOT1;

                        result[0] = pc;
                    }
                    else if (pctype == PCType.OUSTER)
                    {
                        PCOusterInfo pc = GetPCOusterInfo(name1);
                        pc.Slot = Slot.SLOT1;

                        result[0] = pc;
                    }
                }

                if (name2 != null)
                {
                    PCType pctype = GetPCType(name2);
                    if (pctype == PCType.SLAYER)
                    {
                        PCSlayerInfo pc = GetPCSlayerInfo(name2);
                        pc.Slot = Slot.SLOT2;

                        result[1] = pc;
                    }
                    else if (pctype == PCType.VAMPIRE)
                    {
                        PCVampireInfo pc = GetPCVampireInfo(name2);
                        pc.Slot = Slot.SLOT2;

                        result[1] = pc;
                    }
                    else if (pctype == PCType.OUSTER)
                    {
                        PCOusterInfo pc = GetPCOusterInfo(name2);
                        pc.Slot = Slot.SLOT2;

                        result[1] = pc;
                    }
                }

                if (name3 != null)
                {
                    PCType pctype = GetPCType(name3);
                    if (pctype == PCType.SLAYER)
                    {
                        PCSlayerInfo pc = GetPCSlayerInfo(name3);
                        pc.Slot = Slot.SLOT3;

                        result[2] = pc;
                    }
                    else if (pctype == PCType.VAMPIRE)
                    {
                        PCVampireInfo pc = GetPCVampireInfo(name3);
                        pc.Slot = Slot.SLOT3;

                        result[2] = pc;
                    }
                    else if (pctype == PCType.OUSTER)
                    {
                        PCOusterInfo pc = GetPCOusterInfo(name3);
                        pc.Slot = Slot.SLOT3;

                        result[2] = pc;
                    }
                }
            }

            // return result
            return(result);
        }
예제 #11
0
        protected override void ProcessRecord()
        {
            PCInfo pcInfo = PSInfoLib.InfoLib.GetPCInfo();

            WriteObject(pcInfo);
        }
예제 #12
0
        protected void UpdateView(PCInfo[] pcs)
        {
            _allPCs = pcs;

            if (_allPCs == null)
            {
                _waiting.Message = StrRes.MsgNoData;
                _view = new PagedCollectionView(new PCInfo[0]);
            }
            else
            {
                _waiting.IsBusy = false;
                _view = new PagedCollectionView(_allPCs);
            }

            UpdatePCFilter();

            _pager.Source = _view;
            _pcGrid.ItemsSource = _view;
        }
예제 #13
0
 protected void OnCheckedPCChanged(PCInfo oldValue, PCInfo newValue)
 {
     if (newValue == null)
         _pcGrid.SelectedItem = null;
 }