pageRecord m_recordPage; //List with page records

        #endregion Fields

        #region Constructors

        /// <summary>
        /// This method performs a connection to the server,get the first page
        /// of records and populate the grid with it.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            ChannelFactory<IDataController> dataFactory;
            NetTcpBinding tcpBinding = new NetTcpBinding();

            tcpBinding.MaxReceivedMessageSize = System.Int32.MaxValue;
            tcpBinding.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;
            string sURL = "net.tcp://localhost:50001/Data";

            dataFactory = new ChannelFactory<IDataController>(tcpBinding, sURL);

            m_data = dataFactory.CreateChannel();

            string [] columns = m_data.GetColumnNames();

            /*Binds the columns with the name of the fields of the table*/
            foreach (string name in columns)
            {
                DataGridTextColumn textcol = new DataGridTextColumn();
                Binding b = new Binding(name);
                textcol.Binding = b;
                textcol.Header = name;
                dgrdData.Columns.Add(textcol);
            }

            m_recordPage = new pageRecord();
            txtPage.Text = "1";
            UpdateDataGrid(1);
        }
 public GenericServer(IDataController dataController)
 {
     _dataController = dataController;
     ServerErrorReportingEngine.Instance.NewErrorReport += Instance_NewErrorReport;
     GCCollectTimer = new System.Timers.Timer(1000);
     GCCollectTimer.Elapsed += new System.Timers.ElapsedEventHandler(GCCollectTimer_Elapsed);
 }
Пример #3
0
        public ucCompanyForm()
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            LoadData();
        }
Пример #4
0
        public ucEmployeeForm()
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            BindCompany();
        }
Пример #5
0
        public ucWorkingCalendar()
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            BindWorkingCalendar();
        }
Пример #6
0
        public ucAttendanceReport()
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            BindData();
        }
Пример #7
0
        public ucAttendance(int tabNo)
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            if(tabNo == 1)
                tabControl1.SelectedTab = tabPage2;
        }
Пример #8
0
        public frmAddUpdateEmployee(int employeeID)
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            BindData();
            SetState(employeeID);
        }
Пример #9
0
        public frmAddUpdateShift(int shiftID)
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            _shiftID = shiftID;
            SetState(shiftID);
        }
        UpdateResponse m_updateFunction; //Delegate that Calls the update function from main form

        #endregion Fields

        #region Constructors

        /*Initialise the components and loads the data in textboxes, when it is the case*/
        public DialogWindow(int option, dbRecord record, UpdateResponse updateFunction, IDataController data)
        {
            InitializeComponent();
            m_updateFunction = updateFunction;
            m_option = option;
            m_record = record;
            m_data = data;
            LoadInformation();
        }
        public frmAddUpdateAttendanceRecord(int attRecord)
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            BindEmployeeNumber();

            SetState(attRecord);
        }
Пример #12
0
        public frmTerminalRegister(frmAddUpdateEmployee callbackForm)
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            _callbackForm = callbackForm;

            InitializeComponent();

            BindData();
        }
Пример #13
0
        public frmReprocessStatus(string employeeNumberList, DateTime dReprocessFrom, DateTime dReprocessTo)
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            _employeeNumberList = employeeNumberList;
            _dReprocessFrom = dReprocessFrom;
            _dReprocessTo = dReprocessTo;
        }
Пример #14
0
        public frmRoostedDayOff(int rDayOffId)
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            BindEmployeeNumber();

            SetState(rDayOffId);
        }
Пример #15
0
 /// <summary>
 /// Constructor that performs a connection to the server
 /// </summary>
 public Service()
 {
     ChannelFactory<IDataController> dataFactory;
     NetTcpBinding tcpBinding = new NetTcpBinding();
     tcpBinding.MaxReceivedMessageSize = System.Int32.MaxValue;
     tcpBinding.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;
     string sURL = "net.tcp://localhost:50001/Data";
     dataFactory = new ChannelFactory<IDataController>(tcpBinding, sURL);
     m_data = dataFactory.CreateChannel();
 }
Пример #16
0
        public ucDepartmentForm()
        {
            InitializeComponent();

            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;
            BindCompany();
            BindDepartment();
            BindTree();

            LoadForm(0, (int)cbxCompany.SelectedValue, 0, "");
        }
Пример #17
0
		public DataView(TimeFrame timeframe, IDataController controller)
		{
			Timeframe = timeframe;
			_controller = controller;

			_dataItems = new List<IDataItem>();
			_movingAverageCollections = new Dictionary<int, List<double>>();

			//_trendItems = new List<ITrendItem>();
			_trendItems = new List<int>();
		}
Пример #18
0
        public ucUserManagment()
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            BindUser();
            BindEmployeeNumber();

            SetState(-1);
        }
        public frmPreviewWorkingCalendar(int workingCalendarID)
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            SetColor();

            BindWorkingCalendar(workingCalendarID);

            mclWorkingCalendar.ActiveMonth.Month = DateTime.Today.Month;
        }
Пример #20
0
        public ucSetting()
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            BindWeekdays();
            BindRoundValue();
            EnableControls();

            RestoreOldSettings();

            gbxServerSetting.Enabled = Properties.Settings.Default.IsClient;
            gbxBackup.Enabled = !Properties.Settings.Default.IsClient;
            gbxRestore.Enabled = !Properties.Settings.Default.IsClient;
        }
        public frmAddUpdateWorkingCalendar(int workingCalendarID)
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            _workingCalendarID = workingCalendarID;

            _listBreak1 = new Control[] { txtBreakName1, dtpBreakFrom1, dtpBreakTo1, chbBreakPaid1 };
            _listBreak2 = new Control[] { txtBreakName2, dtpBreakFrom2, dtpBreakTo2, chbBreakPaid2 };
            _listBreak3 = new Control[] { txtBreakName3, dtpBreakFrom3, dtpBreakTo3, chbBreakPaid3 };

            _listCbxRate = new ComboBox[]{cbxWorkDayRegularRate, cbxWorkDayOvertimeRate1, cbxWorkDayOvertimeRate2, cbxWorkDayOvertimeRate3, cbxWorkDayOvertimeRate4,
                cbxNonWorkDayRegularRate, cbxNonWorkDayOvertimeRate1, cbxNonWorkDayOvertimeRate2, cbxNonWorkDayOvertimeRate3, cbxNonWorkDayOvertimeRate4,
                cbxHolidayRegularRate, cbxHolidayOvertimeRate1, cbxHolidayOvertimeRate2, cbxHolidayOvertimeRate3, cbxHolidayOvertimeRate4};

            BindData();
            SetState(workingCalendarID);
        }
Пример #22
0
        public bool IsMiniCampaign()
        {
            if (this.miniCampaignAlreadyCalculated)
            {
                return(this.miniCampaign);
            }
            IDataController dataController = Service.Get <IDataController>();

            this.miniCampaign = true;
            foreach (CampaignMissionVO current in dataController.GetAll <CampaignMissionVO>())
            {
                if (current.CampaignUid == this.Uid && current.UnlockOrder > 1)
                {
                    this.miniCampaign = false;
                    break;
                }
            }
            this.miniCampaignAlreadyCalculated = true;
            return(this.miniCampaign);
        }
Пример #23
0
        public static uint GetTrapAttackRadius(TrapTypeVO trapType)
        {
            IDataController dataController = Service.Get <IDataController>();
            TrapEventType   eventType      = trapType.EventType;

            if (eventType == TrapEventType.SpecialAttack)
            {
                string specialAttackName = trapType.ShipTED.SpecialAttackName;
                SpecialAttackTypeVO specialAttackTypeVO = dataController.Get <SpecialAttackTypeVO>(specialAttackName);
                ProjectileTypeVO    projectileType      = specialAttackTypeVO.ProjectileType;
                return((uint)projectileType.SplashRadius);
            }
            if (eventType == TrapEventType.Turret)
            {
                string       turretUid    = trapType.TurretTED.TurretUid;
                TurretTypeVO turretTypeVO = dataController.Get <TurretTypeVO>(turretUid);
                return(turretTypeVO.MaxAttackRange);
            }
            return(0u);
        }
Пример #24
0
        public void SetupStatGridForPerk(PerkVO targetPerkVO, UXGrid statGrid, string templateElement, string descriptionElement, string valueElement, bool useUpgrade)
        {
            Lang            lang           = Service.Get <Lang>();
            IDataController dataController = Service.Get <IDataController>();

            string[] array       = null;
            string[] perkEffects = targetPerkVO.PerkEffects;
            int      num         = perkEffects.Length;

            statGrid.SetTemplateItem(templateElement);
            string perkGroup = targetPerkVO.PerkGroup;
            int    perkTier  = targetPerkVO.PerkTier;

            if (useUpgrade && perkTier > 1)
            {
                PerkVO perkByGroupAndTier = GameUtils.GetPerkByGroupAndTier(perkGroup, perkTier - 1);
                array = perkByGroupAndTier.PerkEffects;
                if (perkEffects.Length != num)
                {
                    Service.Get <StaRTSLogger>().Error("PerkEffects list not consistent between " + perkByGroupAndTier.Uid + " and " + targetPerkVO.Uid);
                }
            }
            statGrid.Clear();
            for (int i = 0; i < num; i++)
            {
                PerkEffectVO perkEffectVO = dataController.Get <PerkEffectVO>(perkEffects[i]);
                PerkEffectVO prevVO       = null;
                if (array != null)
                {
                    prevVO = dataController.Get <PerkEffectVO>(array[i]);
                }
                string    itemUid     = perkEffectVO.Uid + i;
                UXElement item        = statGrid.CloneTemplateItem(itemUid);
                UXLabel   subElement  = statGrid.GetSubElement <UXLabel>(itemUid, descriptionElement);
                UXLabel   subElement2 = statGrid.GetSubElement <UXLabel>(itemUid, valueElement);
                subElement.Text  = lang.Get(perkEffectVO.StatStringId, new object[0]);
                subElement2.Text = this.GetFormattedValueBasedOnEffectType(perkEffectVO, prevVO);
                statGrid.AddItem(item, i);
            }
            statGrid.RepositionItems();
        }
Пример #25
0
        protected override void InitService()
        {
            FactionType     faction        = Service.Get <CurrentPlayer>().Faction;
            IDataController dataController = Service.Get <IDataController>();

            foreach (TroopTypeVO current in dataController.GetAll <TroopTypeVO>())
            {
                if (current.PlayerFacing && current.Faction == faction)
                {
                    if (current.DPS > this.MaxTroopDps)
                    {
                        this.MaxTroopDps = current.DPS;
                    }
                    if (current.Health > this.MaxTroopHealth)
                    {
                        this.MaxTroopHealth = current.Health;
                    }
                }
            }
            Service.Set <TroopUpgradeCatalog>(this);
        }
Пример #26
0
        public static float GetDiscountedCostMultiplier(BuildingTypeVO contractBuildingVO, List <string> perkEffectIds)
        {
            float num = 0f;

            if (perkEffectIds != null)
            {
                IDataController dataController = Service.Get <IDataController>();
                int             i     = 0;
                int             count = perkEffectIds.Count;
                while (i < count)
                {
                    PerkEffectVO perkEffectVO = dataController.Get <PerkEffectVO>(perkEffectIds[i]);
                    if (ContractCostPerkUtils.CanApplyEffect(perkEffectVO, contractBuildingVO))
                    {
                        num += perkEffectVO.ContractDiscount;
                    }
                    i++;
                }
            }
            return(1f - num);
        }
 public void ReadRow(Row row)
 {
     this.Uid           = row.Uid;
     this.TroopID       = row.TryGetString(TroopUniqueAbilityDescVO.COLUMN_unitID);
     this.AbilityTitle1 = row.TryGetString(TroopUniqueAbilityDescVO.COLUMN_abilityTitle1);
     this.AbilityDesc1  = row.TryGetString(TroopUniqueAbilityDescVO.COLUMN_abilityDesc1);
     this.AbilityTitle2 = row.TryGetString(TroopUniqueAbilityDescVO.COLUMN_abilityTitle2);
     this.AbilityDesc2  = row.TryGetString(TroopUniqueAbilityDescVO.COLUMN_abilityDesc2);
     if (!string.IsNullOrEmpty(this.TroopID))
     {
         IDataController dataController = Service.Get <IDataController>();
         Dictionary <string, TroopTypeVO> .ValueCollection all = dataController.GetAll <TroopTypeVO>();
         foreach (TroopTypeVO current in all)
         {
             if (current.TroopID == this.TroopID)
             {
                 current.UniqueAbilityDescVO = this;
             }
         }
     }
 }
Пример #28
0
        private static void AddEffectsOfMatchingCurrencyType(PerkVO perkData, CurrencyType currencyType, uint startTime, uint endTime, ref List <CurrencyPerkEffectDataTO> matchingEffects)
        {
            if (matchingEffects == null)
            {
                Service.Get <StaRTSLogger>().Error("AddEffectsOfMatchingCurrencyType received null vo list");
                return;
            }
            IDataController dataController = Service.Get <IDataController>();

            string[] perkEffects = perkData.PerkEffects;
            int      num         = perkEffects.Length;

            for (int i = 0; i < num; i++)
            {
                PerkEffectVO perkEffectVO = dataController.Get <PerkEffectVO>(perkEffects[i]);
                if (perkEffectVO.Type == "generator" && perkEffectVO.Currency == currencyType)
                {
                    matchingEffects.Add(new CurrencyPerkEffectDataTO(perkEffectVO.GenerationRate, startTime, endTime));
                }
            }
        }
        public frmAddUpdateWorkingCalendar(int workingCalendarID)
        {
            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();

            _workingCalendarID = workingCalendarID;

            _listCtrlBreak1 = new Control[] { txtBreakName1, dtpBreakFrom1, dtpBreakTo1, chbBreakPaid1 };
            _listCtrlBreak2 = new Control[] { txtBreakName2, dtpBreakFrom2, dtpBreakTo2, chbBreakPaid2 };
            _listCtrlBreak3 = new Control[] { txtBreakName3, dtpBreakFrom3, dtpBreakTo3, chbBreakPaid3 };

            _listCbxRate = new ComboBox[] { cbxWorkDayRegularRate, cbxWorkDayOvertimeRate1, cbxWorkDayOvertimeRate2, cbxWorkDayOvertimeRate3, cbxWorkDayOvertimeRate4,
                                            cbxNonWorkDayRegularRate, cbxNonWorkDayOvertimeRate1, cbxNonWorkDayOvertimeRate2, cbxNonWorkDayOvertimeRate3, cbxNonWorkDayOvertimeRate4,
                                            cbxHolidayRegularRate, cbxHolidayOvertimeRate1, cbxHolidayOvertimeRate2, cbxHolidayOvertimeRate3, cbxHolidayOvertimeRate4,
                                            cbxFlexiHourWorkingDayRegularRate, cbxFlexiHourNonWorkingDayRegularRate, cbxFlexiHourHolidayRegularRate, cbxFlexiHourOvertimeRate1, cbxFlexiHourOvertimeRate2, cbxFlexiHourOvertimeRate3, cbxFlexiHourOvertimeRate4 };

            BindWeekdays();
            BindData();
            SetState(workingCalendarID);
        }
Пример #30
0
 public AudioManager(AssetsCompleteDelegate onComplete)
 {
     Service.Set <AudioManager>(this);
     this.logger = Service.Get <StaRTSLogger>();
     this.sdc    = Service.Get <IDataController>();
     new AudioEventManager(this);
     this.audioObject = new GameObject("Audio");
     this.audioObject.AddComponent <AudioListener>();
     this.audioObject.transform.position = Vector3.zero;
     this.audioSources = new Dictionary <AudioCategory, AudioSource>();
     this.audioSources[AudioCategory.Effect]   = this.CreateAudioSource(128);
     this.audioSources[AudioCategory.Music]    = this.CreateAudioSource(0);
     this.audioSources[AudioCategory.Ambience] = this.CreateAudioSource(10);
     this.audioSources[AudioCategory.Dialogue] = this.CreateAudioSource(20);
     this.loadedAudio       = new Dictionary <AudioTypeVO, AudioData>();
     this.fadeOutDictionary = new Dictionary <AudioSource, AudioFader>();
     this.battleAudioFlags  = new bool[8];
     this.lastPlayed        = new AudioTypeVO[4];
     this.RefreshVolume();
     this.PreloadAudioAssets(onComplete);
 }
Пример #31
0
        public void ReadRow(Row row)
        {
            this.Uid = row.Uid;
            IDataController dataController = Service.Get <IDataController>();
            string          text           = row.TryGetString(SkinOverrideTypeVO.COLUMN_projectileType);

            if (!string.IsNullOrEmpty(text))
            {
                this.ProjectileType = dataController.Get <ProjectileTypeVO>(row.TryGetString(SkinOverrideTypeVO.COLUMN_projectileType));
            }
            this.WarmupDelay    = row.TryGetUint(SkinOverrideTypeVO.COLUMN_chargeTime);
            this.AnimationDelay = row.TryGetUint(SkinOverrideTypeVO.COLUMN_animationDelay);
            this.ShotDelay      = row.TryGetUint(SkinOverrideTypeVO.COLUMN_shotDelay);
            this.CooldownDelay  = row.TryGetUint(SkinOverrideTypeVO.COLUMN_reload);
            this.ShotCount      = row.TryGetUint(SkinOverrideTypeVO.COLUMN_shotCount);
            ValueObjectController valueObjectController = Service.Get <ValueObjectController>();
            SequencePair          gunSequences          = valueObjectController.GetGunSequences(this.Uid, row.TryGetString(SkinOverrideTypeVO.COLUMN_gunSequence));

            this.GunSequence = gunSequences.GunSequence;
            this.Sequences   = gunSequences.Sequences;
        }
Пример #32
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.ContractCompleted)
     {
         IDataController   dataController    = Service.Get <IDataController>();
         ContractEventData contractEventData = (ContractEventData)cookie;
         Contract          contract          = contractEventData.Contract;
         DeliveryType      deliveryType      = contract.DeliveryType;
         if (deliveryType == DeliveryType.Infantry || deliveryType == DeliveryType.Vehicle || deliveryType == DeliveryType.Mercenary)
         {
             TroopTypeVO troop = dataController.Get <TroopTypeVO>(contract.ProductUid);
             if (this.IsTroopValid(troop))
             {
                 this.unitsTrained++;
                 this.parent.ChildUpdated(this, 1);
                 this.EvaluateAmount();
             }
         }
     }
     return(EatResponse.NotEaten);
 }
        public static int GetRelocationCostDiscount(List <string> perkEffectIds)
        {
            int num = 0;

            if (perkEffectIds != null)
            {
                IDataController dataController = Service.Get <IDataController>();
                int             i     = 0;
                int             count = perkEffectIds.Count;
                while (i < count)
                {
                    PerkEffectVO perkEffectVO = dataController.Get <PerkEffectVO>(perkEffectIds[i]);
                    if (RelocationCostPerkUtils.CanApplyEffect(perkEffectVO))
                    {
                        num += perkEffectVO.RelocationDiscount;
                    }
                    i++;
                }
            }
            return(num);
        }
Пример #34
0
        public void GrantUnlockShards(string shardId, int count)
        {
            CurrentPlayer            currentPlayer  = Service.Get <CurrentPlayer>();
            Dictionary <string, int> shards         = currentPlayer.Shards;
            IDataController          dataController = Service.Get <IDataController>();
            ShardVO shardVO       = dataController.Get <ShardVO>(shardId);
            string  targetType    = shardVO.TargetType;
            string  targetGroupId = shardVO.TargetGroupId;
            int     num           = count;

            if (shards.ContainsKey(shardId))
            {
                num += shards[shardId];
            }
            currentPlayer.ModifyShardAmount(shardId, num);
            int upgradeLevelOfDeployable = this.GetUpgradeLevelOfDeployable(targetType, targetGroupId);

            if (upgradeLevelOfDeployable == 0)
            {
                this.AttemptToUpgradeUnitWithShards(shardId, 1);
                return;
            }
            IDeployableVO deployableVOForLevelInGroup = this.GetDeployableVOForLevelInGroup(upgradeLevelOfDeployable, targetType, targetGroupId);

            if (deployableVOForLevelInGroup == null)
            {
                Service.Get <StaRTSLogger>().ErrorFormat("No deployableVO found for targetType: {0}, targetGroup: {1}, upgradeLevel: {2}", new object[]
                {
                    targetType,
                    targetGroupId,
                    upgradeLevelOfDeployable
                });
                return;
            }
            if (num - count < deployableVOForLevelInGroup.UpgradeShardCount && num >= deployableVOForLevelInGroup.UpgradeShardCount)
            {
                this.AllowResearchBuildingBadging = true;
                Service.Get <EventManager>().SendEvent(EventId.ShardUnitNowUpgradable, deployableVOForLevelInGroup.Uid);
            }
        }
        private bool IsEquipmentActiveOnDeployable(IDataController sdc, string deployableUid)
        {
            CurrentBattle currentBattle = Service.Get <BattleController>().GetCurrentBattle();
            List <string> list          = (currentBattle.Type == BattleType.PveDefend) ? currentBattle.DefenderEquipment : currentBattle.AttackerEquipment;

            if (list == null)
            {
                return(false);
            }
            if (deployableUid.Equals("squadTroops"))
            {
                return(false);
            }
            string text  = this.IsStarship ? sdc.Get <SpecialAttackTypeVO>(deployableUid).SpecialAttackID : sdc.Get <TroopTypeVO>(deployableUid).TroopID;
            int    i     = 0;
            int    count = list.Count;

            while (i < count)
            {
                EquipmentVO equipmentVO = sdc.Get <EquipmentVO>(list[i]);
                for (int j = 0; j < equipmentVO.EffectUids.Length; j++)
                {
                    EquipmentEffectVO equipmentEffectVO = sdc.Get <EquipmentEffectVO>(equipmentVO.EffectUids[j]);
                    string[]          array             = this.IsStarship ? equipmentEffectVO.AffectedSpecialAttackIds : equipmentEffectVO.AffectedTroopIds;
                    if (array != null)
                    {
                        for (int k = 0; k < array.Length; k++)
                        {
                            if (array[k] == text)
                            {
                                return(true);
                            }
                        }
                    }
                }
                i++;
            }
            return(false);
        }
Пример #36
0
        protected void PrepareButton(ICallToAction vo, int btnIndex, UXButton button, UXLabel btnLabel)
        {
            if (button == null || btnLabel == null)
            {
                return;
            }
            string text = (btnIndex == 1) ? vo.Btn1 : vo.Btn2;

            if (string.IsNullOrEmpty(text))
            {
                button.Visible = false;
                return;
            }
            button.Visible = true;
            if (btnIndex == 1)
            {
                button.OnClicked = new UXButtonClickedDelegate(this.FeaturedButton1Clicked);
            }
            else
            {
                button.OnClicked = new UXButtonClickedDelegate(this.FeaturedButton2Clicked);
            }
            button.Tag    = vo;
            btnLabel.Text = this.lang.Get(text, new object[0]);
            if (this.IsButtonRewardAction(vo, btnIndex))
            {
                IDataController     dataController = Service.Get <IDataController>();
                LimitedTimeRewardVO vo2;
                if (btnIndex == 1)
                {
                    vo2 = dataController.Get <LimitedTimeRewardVO>(vo.Btn1Data);
                }
                else
                {
                    vo2 = dataController.Get <LimitedTimeRewardVO>(vo.Btn2Data);
                }
                this.SetupRewardButton(ref button, ref btnLabel, vo2);
            }
        }
Пример #37
0
		public ReceiverProxy(IDataProvider dataProvider, IDataController dataController)
		{
			System.Diagnostics.Debug.Assert(dataProvider != null);
			
			_dataProvider = dataProvider;
			if (_dataProvider != null)
			{
				_dataProvider.DataReceived += OnDataReceived;
			}

			System.Diagnostics.Debug.Assert(dataController != null);
			_dataController = dataController;
			if (_dataController != null)
			{
				_dataController.ProcessingCompleted += ProcessingCompleted;
			}

			_cacheDataLocally = false;
			_cachedItems = new List<IDataItem>();

			ForceSequentialAccess = true;
		}
Пример #38
0
        private FinishNowScreen(Entity buildingEntity, Contract currentContract, bool noContract) : base(false, null, null, null, false)
        {
            this.buildingEntity  = buildingEntity;
            this.perkId          = null;
            this.currentContract = currentContract;
            this.noContract      = noContract;
            IDataController dataController = Service.Get <IDataController>();

            if (currentContract != null)
            {
                switch (currentContract.DeliveryType)
                {
                case DeliveryType.Building:
                    this.displayName = LangUtils.GetBuildingDisplayName(buildingEntity.Get <BuildingComponent>().BuildingType);
                    break;

                case DeliveryType.UpgradeBuilding:
                    this.displayName = LangUtils.GetBuildingDisplayName(buildingEntity.Get <BuildingComponent>().BuildingType);
                    break;

                case DeliveryType.UpgradeTroop:
                    this.displayName = LangUtils.GetTroopDisplayName(dataController.Get <TroopTypeVO>(currentContract.ProductUid));
                    break;

                case DeliveryType.UpgradeStarship:
                    this.displayName = LangUtils.GetStarshipDisplayName(dataController.Get <SpecialAttackTypeVO>(currentContract.ProductUid));
                    break;

                case DeliveryType.UpgradeEquipment:
                    this.displayName = LangUtils.GetEquipmentDisplayName(dataController.Get <EquipmentVO>(currentContract.ProductUid));
                    break;
                }
            }
            else
            {
                this.displayName = LangUtils.GetBuildingDisplayName(buildingEntity.Get <BuildingComponent>().BuildingType);
            }
            this.RefreshData();
        }
        public void Save(string fileName)
        {
            IDataController dataController         = Service.Get <IDataController>();
            CombatEncounter currentCombatEncounter = this.GetCurrentCombatEncounter();
            List <Building> buildings = currentCombatEncounter.map.Buildings;
            int             i         = 0;
            int             count     = buildings.Count;

            while (i < count)
            {
                buildings[i].Key = "bld_" + (i + 1);
                if (dataController.Get <BuildingTypeVO>(buildings[i].Uid).Type == BuildingType.Trap)
                {
                    buildings[i].CurrentStorage = 1;
                }
                i++;
            }
            string text = this.Serialize(currentCombatEncounter);

            FileUtils.Write(FileUtils.GetAbsFilePathInMyDocuments(fileName, "/src/maps"), text);
            Service.Get <StaRTSLogger>().Debug("Json Saved: " + text);
        }
Пример #40
0
        public void UpdateValidLEIs()
        {
            this.ValidLEIs.Clear();
            IDataController dataController = Service.Get <IDataController>();
            CurrentPlayer   player         = Service.Get <CurrentPlayer>();
            int             serverTime     = (int)Service.Get <ServerAPI>().ServerTime;

            Dictionary <string, LimitedEditionItemVO> .ValueCollection all = dataController.GetAll <LimitedEditionItemVO>();
            int num = -1;

            foreach (LimitedEditionItemVO current in all)
            {
                int num2 = current.EndTime - serverTime;
                if (num2 >= 0)
                {
                    if (num == -1 || num2 < num)
                    {
                        num = num2;
                    }
                    int num3 = current.StartTime - serverTime;
                    if (num3 > 0)
                    {
                        if (num == -1 || num3 < num)
                        {
                            num = num3;
                        }
                    }
                    else if (LimitedEditionItemController.IsValidForPlayer(current, player))
                    {
                        this.ValidLEIs.Add(current);
                    }
                }
            }
            if (num != -1 && (long)num < 432000L)
            {
                this.nextUpdateTimer = Service.Get <ViewTimerManager>().CreateViewTimer((float)num, false, new TimerDelegate(this.UpdateValidLEIs), null);
            }
        }
Пример #41
0
        private bool IsBuildingUnlockedByRequirement(BuildingTypeVO vo, int buildOrUpgrade, ref BuildingTypeVO req)
        {
            bool flag = true;

            if (buildOrUpgrade == 0)
            {
                vo = Service.Get <BuildingUpgradeCatalog>().GetMinLevel(vo);
            }
            BuildingLookupController buildingLookupController = Service.Get <BuildingLookupController>();
            IDataController          dataController           = Service.Get <IDataController>();

            if (!string.IsNullOrEmpty(vo.BuildingRequirement))
            {
                req  = dataController.Get <BuildingTypeVO>(vo.BuildingRequirement);
                flag = buildingLookupController.HasConstructedBuilding(req);
            }
            if (flag && !string.IsNullOrEmpty(vo.BuildingRequirement2))
            {
                req  = dataController.Get <BuildingTypeVO>(vo.BuildingRequirement2);
                flag = buildingLookupController.HasConstructedBuilding(req);
            }
            return(flag);
        }
Пример #42
0
        public static int GetTroopRequestPerkTimeReduction(List <string> perkEffectIds)
        {
            int num = 0;

            if (perkEffectIds != null)
            {
                IDataController dataController = Service.Get <IDataController>();
                int             i     = 0;
                int             count = perkEffectIds.Count;
                while (i < count)
                {
                    PerkEffectVO perkEffectVO = dataController.Get <PerkEffectVO>(perkEffectIds[i]);
                    string       type         = perkEffectVO.Type;
                    BuildingType perkBuilding = perkEffectVO.PerkBuilding;
                    if (type == "troopRequestTime" && perkBuilding == BuildingType.Squad)
                    {
                        num += perkEffectVO.TroopRequestTimeDiscount;
                    }
                    i++;
                }
            }
            return(num);
        }
        private bool CanPurchaseIAPLinkedOffer(TargetedBundleVO currentOffer)
        {
            bool            flag           = true;
            IDataController dataController = Service.Get <IDataController>();
            int             i     = 0;
            int             count = currentOffer.RewardUIDs.Count;

            while (i < count)
            {
                RewardVO optional = dataController.GetOptional <RewardVO>(currentOffer.RewardUIDs[i]);
                if (optional != null && optional.BuildingInstantRewards != null)
                {
                    flag = this.CanPlaceAllRewardBuildings(optional.BuildingInstantRewards);
                    if (!flag)
                    {
                        AlertScreen.ShowModal(false, Service.Get <Lang>().Get("promo_error_nospace_title", new object[0]), Service.Get <Lang>().Get("promo_error_nospace_desc", new object[0]), null, null);
                        break;
                    }
                }
                i++;
            }
            return(flag);
        }
        private void UpdateElements()
        {
            IDataController dataController = Service.Get <IDataController>();

            if (this.currentOffer != null)
            {
                UXLabel element = base.GetElement <UXLabel>("LabelTitle");
                element.Text = this.lang.Get(this.currentOffer.Title, new object[0]);
                UXLabel element2 = base.GetElement <UXLabel>("LabelDescription");
                element2.Text = this.lang.Get(this.currentOffer.ConfirmationString, new object[0]);
                int i     = 0;
                int count = this.currentOffer.RewardUIDs.Count;
                while (i < count)
                {
                    RewardVO rewardVO = dataController.Get <RewardVO>(this.currentOffer.RewardUIDs[i]);
                    if (!RewardUtils.SetupTargetedOfferCrateRewardDisplay(rewardVO, this.itemLabels[i], this.itemSprites[i]))
                    {
                        List <RewardComponentTag> rewardComponents = RewardUtils.GetRewardComponents(rewardVO);
                        int j      = 0;
                        int count2 = rewardComponents.Count;
                        while (j < count2)
                        {
                            RewardComponentTag rewardComponentTag = rewardComponents[j];
                            this.itemLabels[i].Text = this.lang.Get("AMOUNT_AND_NAME", new object[]
                            {
                                rewardComponentTag.RewardName,
                                rewardComponentTag.Quantity
                            });
                            RewardUtils.SetRewardIcon(this.itemSprites[i], rewardComponentTag.RewardGeometryConfig, AnimationPreference.NoAnimation);
                            j++;
                        }
                    }
                    i++;
                }
                this.confirmButton.Tag = this.currentOffer;
            }
        }
Пример #45
0
        private void ApplyBuildingEquipmentBuffs(SmartEntity entity)
        {
            if (entity.TeamComp == null || entity.BuildingComp == null)
            {
                return;
            }
            IDataController          dataController        = Service.Get <IDataController>();
            List <EquipmentEffectVO> equipmentBuffsForTeam = this.GetEquipmentBuffsForTeam(entity.TeamComp.TeamType);
            int num = (equipmentBuffsForTeam != null) ? equipmentBuffsForTeam.Count : 0;

            for (int i = 0; i < num; i++)
            {
                EquipmentEffectVO equipmentEffectVO = equipmentBuffsForTeam[i];
                if (equipmentEffectVO.BuffUids != null && equipmentEffectVO.AffectedBuildingIds != null)
                {
                    string buildingID = entity.BuildingComp.BuildingType.BuildingID;
                    int    j          = 0;
                    int    num2       = equipmentEffectVO.AffectedBuildingIds.Length;
                    while (j < num2)
                    {
                        if (equipmentEffectVO.AffectedBuildingIds[j] == buildingID)
                        {
                            int k    = 0;
                            int num3 = equipmentEffectVO.BuffUids.Length;
                            while (k < num3)
                            {
                                BuffTypeVO buffType = dataController.Get <BuffTypeVO>(equipmentEffectVO.BuffUids[k]);
                                this.TryAddBuffStack(entity, buffType, BuffController.DeduceArmorType(entity), BuffVisualPriority.Equipment);
                                k++;
                            }
                            break;
                        }
                        j++;
                    }
                }
            }
        }
Пример #46
0
        protected override void OnScreenLoaded()
        {
            this.InitButtons();
            this.playerNameLabel       = base.GetElement <UXLabel>("LabelPlayerName");
            this.attacksRemainingLabel = base.GetElement <UXLabel>("LabelAttacksRemaining");
            this.uplinksAvailableLabel = base.GetElement <UXLabel>("LabelUplinksAvailable");
            this.factionSprite         = base.GetElement <UXSprite>("SpriteFactionIcon");
            this.factionDefaultSprite  = base.GetElement <UXSprite>("SpriteFactionIconZero");
            this.playerDetailTexture   = base.GetElement <UXTexture>("TexturePlayerDetails");
            IDataController dataController = Service.Get <IDataController>();
            TextureVO       optional       = dataController.GetOptional <TextureVO>("squadwars_playerdetails_bg");

            if (optional != null)
            {
                this.playerDetailTexture.LoadTexture(optional.AssetName);
            }
            for (int i = 1; i <= 3; i++)
            {
                this.requirements.Add(base.GetElement <UXLabel>(string.Format("LabelStarRequirement{0}", new object[]
                {
                    i
                })));
                this.uplinks.Add(base.GetElement <UXSprite>(string.Format("SpriteUplink{0}", new object[]
                {
                    i
                })));
                this.checks.Add(base.GetElement <UXSprite>(string.Format("SpriteCheck{0}", new object[]
                {
                    i
                })));
                this.stars.Add(base.GetElement <UXElement>(string.Format("DamageStars{0}", new object[]
                {
                    i
                })));
            }
            this.RefreshView();
        }
Пример #47
0
 private void ClaimReward(string limitedTimeRewardUid, string contextUid)
 {
     if (!string.IsNullOrEmpty(contextUid))
     {
         IDataController     dataController = Service.Get <IDataController>();
         LimitedTimeRewardVO optional       = dataController.GetOptional <LimitedTimeRewardVO>(limitedTimeRewardUid);
         if (optional == null)
         {
             Service.Get <StaRTSLogger>().WarnFormat("No LimitedTimeReward data found for uid: {0}", new object[]
             {
                 limitedTimeRewardUid
             });
             return;
         }
         RewardVO optional2 = dataController.GetOptional <RewardVO>(optional.RewardUid);
         if (optional2 == null)
         {
             Service.Get <StaRTSLogger>().WarnFormat("LimitedTimeReward {0} points to reward {1} but it was not found", new object[]
             {
                 limitedTimeRewardUid,
                 optional.RewardUid
             });
             return;
         }
         HolonetClaimRewardRequest request = new HolonetClaimRewardRequest(limitedTimeRewardUid, contextUid);
         HolonetClaimRewardCommand command = new HolonetClaimRewardCommand(request);
         Service.Get <ServerAPI>().Sync(command);
         GameUtils.AddRewardToInventory(optional2);
         Service.Get <CurrentPlayer>().AddHolonetReward(limitedTimeRewardUid);
         Lang   lang = Service.Get <Lang>();
         string text = lang.Get(optional.Title, new object[0]);
         AlertScreen.ShowModal(false, lang.Get("hn_reward_redeemed", new object[0]), lang.Get("hn_reward_claimed_desc", new object[]
         {
             text
         }), null, null);
     }
 }
Пример #48
0
        public SkinTypeVO GetApplicableSkin(TroopTypeVO troop, List <string> equipmentList, out string equipmentUid)
        {
            equipmentUid = null;
            if (troop == null || equipmentList == null)
            {
                return(null);
            }
            IDataController dataController = Service.Get <IDataController>();
            int             i     = 0;
            int             count = equipmentList.Count;

            while (i < count)
            {
                EquipmentVO equipmentVO = dataController.Get <EquipmentVO>(equipmentList[i]);
                if (equipmentVO != null)
                {
                    string[] skins = equipmentVO.Skins;
                    if (skins != null)
                    {
                        int j   = 0;
                        int num = skins.Length;
                        while (j < num)
                        {
                            SkinTypeVO skinTypeVO = dataController.Get <SkinTypeVO>(skins[j]);
                            if (troop.TroopID.Equals(skinTypeVO.UnitId))
                            {
                                equipmentUid = equipmentList[i];
                                return(skinTypeVO);
                            }
                            j++;
                        }
                    }
                }
                i++;
            }
            return(null);
        }
        public ValidateProductFilesActivity(
            IGetDirectoryDelegate productFileDirectoryDelegate,
            IGetFilenameDelegate productFileFilenameDelegate,
            IFormatDelegate <string, string> formatValidationFileDelegate,
            IFileValidationController fileValidationController,
            IDataController <ValidationResult> validationResultsDataController,
            IDataController <GameDetails> gameDetailsDataController,
            IItemizeAsyncDelegate <GameDetails, string> itemizeGameDetailsManualUrlsAsyncDelegate,
            IItemizeAllAsyncDelegate <long> itemizeAllProductsAsyncDelegate,
            IRoutingController routingController,
            IStatusController statusController) :
            base(statusController)
        {
            this.productFileDirectoryDelegate              = productFileDirectoryDelegate;
            this.productFileFilenameDelegate               = productFileFilenameDelegate;
            this.formatValidationFileDelegate              = formatValidationFileDelegate;
            this.fileValidationController                  = fileValidationController;
            this.validationResultsDataController           = validationResultsDataController;
            this.gameDetailsDataController                 = gameDetailsDataController;
            this.itemizeGameDetailsManualUrlsAsyncDelegate = itemizeGameDetailsManualUrlsAsyncDelegate;

            this.itemizeAllProductsAsyncDelegate = itemizeAllProductsAsyncDelegate;
            this.routingController = routingController;
        }
Пример #50
0
        public int FindHighestHqLevel()
        {
            IDataController dataController = Service.Get <IDataController>();
            int             num            = -1;
            int             num2           = num;

            if (dataController == null || this.Buildings == null)
            {
                return(num2);
            }
            int i     = 0;
            int count = this.Buildings.Count;

            while (i < count)
            {
                BuildingTypeVO optional = dataController.GetOptional <BuildingTypeVO>(this.Buildings[i].Uid);
                if (optional != null && optional.Type == BuildingType.HQ && optional.Lvl >= num2)
                {
                    num2 = optional.Lvl;
                }
                i++;
            }
            return(num2);
        }
Пример #51
0
        private void UpdateBuildings(FactionType newFaction)
        {
            IDataController       dataController = Service.Get <IDataController>();
            List <BuildingTypeVO> list           = new List <BuildingTypeVO>();

            foreach (BuildingTypeVO current in dataController.GetAll <BuildingTypeVO>())
            {
                list.Add(current);
            }
            list.Sort(new Comparison <BuildingTypeVO>(GameUtils.SortBuildingByUID));
            List <Building> buildings = Service.Get <CurrentPlayer>().Map.Buildings;

            for (int i = 0; i < buildings.Count; i++)
            {
                Building       building       = buildings[i];
                BuildingTypeVO buildingTypeVO = dataController.Get <BuildingTypeVO>(building.Uid);
                if (buildingTypeVO.Faction != FactionType.Neutral)
                {
                    building.Uid = GameUtils.GetEquivalentFromPreSortedList(list, buildingTypeVO, newFaction);
                }
            }
            list.Clear();
            list = null;
        }
Пример #52
0
        public static bool HasExistingHeroContract(string heroUpgradeGroup)
        {
            bool                     result                   = false;
            IDataController          dataController           = Service.Get <IDataController>();
            ISupportController       supportController        = Service.Get <ISupportController>();
            BuildingLookupController buildingLookupController = Service.Get <BuildingLookupController>();
            BuildingComponent        buildingComp             = buildingLookupController.TacticalCommandNodeList.Head.BuildingComp;
            string                   key  = buildingComp.BuildingTO.Key;
            List <Contract>          list = supportController.FindAllTroopContractsForBuilding(key);
            int i     = 0;
            int count = list.Count;

            while (i < count)
            {
                TroopTypeVO troopTypeVO = dataController.Get <TroopTypeVO>(list[i].ProductUid);
                if (troopTypeVO.UpgradeGroup == heroUpgradeGroup)
                {
                    result = true;
                    break;
                }
                i++;
            }
            return(result);
        }
Пример #53
0
        public void DoTasks()
        {
            if (Properties.Settings.Default.IsClient == false) //server only
            {
                _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

                if (isRunningThread(_thrBackupDatabase) == false)
                {
                    try
                    {
                        _thrBackupDatabase = new Thread(new ThreadStart(BackupDatabase));
                        _thrBackupDatabase.Start();
                    }
                    catch { }
                }
                if (isRunningThread(_thrRemindBackup) == false)
                {
                    try
                    {
                        _thrRemindBackup = new Thread(new ThreadStart(RemindBackupDatabase));
                        _thrRemindBackup.Start();
                    }
                    catch { }
                }

                if (isRunningThread(_thrRemoveEmployee) == false)
                {
                    try
                    {
                        _thrRemoveEmployee = new Thread(new ThreadStart(RemoveEmployeeFromTerminal));
                        _thrRemoveEmployee.Start();
                    }
                    catch { }
                }
            }
        }
Пример #54
0
 public TerminalController()
 {
     _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;
 }
Пример #55
0
        public Test()
        {
            _dtCtrl = FaceIDAppVBEta.Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;

            InitializeComponent();
        }
Пример #56
0
        private void AddTestOneShiftNonFlexi(ref IDataController _dtCtrl)
        {
            #region add test company
            Company com = new Company();
            com.Name = DateTime.Now.Ticks.ToString();
            com.ID = _dtCtrl.AddCompany(com);
            #endregion

            #region add test department
            Department dep = new Department();
            dep.CompanyID = com.ID;
            dep.Name = DateTime.Now.Ticks.ToString();
            dep.SupDepartmentID = 0; //root
            dep.ID = _dtCtrl.AddDepartment(dep);
            #endregion

            #region add test working calendar
            WorkingCalendar wCal = new WorkingCalendar();

            wCal.Name = DateTime.Now.Ticks.ToString();

            wCal.WorkOnMonday = true;
            wCal.WorkOnTuesday = true;
            wCal.WorkOnWednesday = true;
            wCal.WorkOnThursday = true;
            wCal.WorkOnFriday = true;

            wCal.GraceForwardToEntry = 30;
            wCal.GraceBackwardToExit = 30;
            wCal.EarliestBeforeEntry = 60;
            wCal.LastestAfterExit = 180;

            List<Shift> shiftList = new List<Shift>();
            Shift shift1 = new Shift();
            shift1.From = new DateTime(2000, 2, 2, 9, 0, 0);
            shift1.To = new DateTime(2000, 2, 2, 18, 0, 0);
            shiftList.Add(shift1);

            List<Break> breakList = new List<Break>();
            Break break1 = new Break();
            break1.From = new DateTime(2000, 2, 2, 12, 0, 0);
            break1.To = new DateTime(2000, 2, 2, 13, 0, 0);
            break1.Name = "break1";
            break1.Paid = true;

            breakList.Add(break1);

            List<Holiday> holidayList = new List<Holiday>();

            PaymentRate workingDayPaymentRate = new PaymentRate();
            workingDayPaymentRate.NumberOfRegularHours = 7;
            workingDayPaymentRate.RegularRate = 100;
            workingDayPaymentRate.NumberOfOvertime1 = 8;
            workingDayPaymentRate.OvertimeRate1 = 200;

            PaymentRate nonWorkingDayPaymentRate = workingDayPaymentRate;
            PaymentRate holidayPaymentRate = workingDayPaymentRate;

            PayPeriod payPeriod = new PayPeriod();
            payPeriod.CustomPeriod = 5;
            payPeriod.PayPeriodTypeID = 5; //custom
            payPeriod.StartFrom = new DateTime(2010, 1, 1);

            wCal.ID = _dtCtrl.AddWorkingCalendar(wCal, shiftList, breakList, holidayList, workingDayPaymentRate, nonWorkingDayPaymentRate, holidayPaymentRate, payPeriod);
            #endregion

            #region add test employee
            Employee emp = new Employee();
            emp.Active = true;
            emp.ActiveFrom = DateTime.Today;
            emp.ActiveTo = DateTime.Today.AddDays(1);
            emp.Address = DateTime.Now.Ticks.ToString();
            emp.Birthday = DateTime.Today.AddYears(-20);
            emp.DepartmentID = dep.ID;
            emp.EmployeeNumber = 0;
            emp.FirstName = DateTime.Now.Ticks.ToString();
            emp.JobDescription = DateTime.Now.Ticks.ToString();
            emp.HiredDate = DateTime.Today;
            emp.LeftDate = DateTime.Today.AddYears(1);
            emp.LastName = DateTime.Now.Ticks.ToString();
            emp.PhoneNumber = DateTime.Now.Ticks.ToString();
            emp.WorkingCalendarID = wCal.ID;
            emp.PayrollNumber = _dtCtrl.AddEmployee(emp, new List<Terminal>());
            #endregion

            #region add test att records 1
            //att1 : expected totalHours: 9
            AttendanceRecord att11 = new AttendanceRecord();
            att11.EmployeeNumber = emp.EmployeeNumber;
            att11.Time = new DateTime(2010, 1, 1, 9, 0, 0);
            att11.ID = _dtCtrl.AddAttendanceRecord(att11);

            AttendanceRecord att12 = new AttendanceRecord();
            att12.EmployeeNumber = emp.EmployeeNumber;
            att12.Time = new DateTime(2010, 1, 1, 18, 0, 0);
            att12.ID = _dtCtrl.AddAttendanceRecord(att12);

            AttendanceRecord att13 = new AttendanceRecord();
            att13.EmployeeNumber = emp.EmployeeNumber;
            att13.Time = new DateTime(2010, 1, 1, 12, 0, 0);
            att13.ID = _dtCtrl.AddAttendanceRecord(att13);

            AttendanceRecord att14 = new AttendanceRecord();
            att14.EmployeeNumber = emp.EmployeeNumber;
            att14.Time = new DateTime(2010, 1, 1, 13, 0, 0);
            att14.ID = _dtCtrl.AddAttendanceRecord(att14);

            //att2 : expected totalHours: 9
            AttendanceRecord att21 = new AttendanceRecord();
            att21.EmployeeNumber = emp.EmployeeNumber;
            att21.Time = new DateTime(2010, 1, 2, 8, 45, 0);
            att21.ID = _dtCtrl.AddAttendanceRecord(att21);

            AttendanceRecord att22 = new AttendanceRecord();
            att22.EmployeeNumber = emp.EmployeeNumber;
            att22.Time = new DateTime(2010, 1, 2, 18, 15, 0);
            att22.ID = _dtCtrl.AddAttendanceRecord(att22);

            //att3 : expected totalHours: 9.75
            AttendanceRecord att31 = new AttendanceRecord();
            att31.EmployeeNumber = emp.EmployeeNumber;
            att31.Time = new DateTime(2010, 1, 3, 8, 15, 0);
            att31.ID = _dtCtrl.AddAttendanceRecord(att31);

            AttendanceRecord att32 = new AttendanceRecord();
            att32.EmployeeNumber = emp.EmployeeNumber;
            att32.Time = new DateTime(2010, 1, 3, 18, 0, 0);
            att32.ID = _dtCtrl.AddAttendanceRecord(att32);

            //att4 : expected totalHours: 0 + out mistake alert
            AttendanceRecord att41 = new AttendanceRecord();
            att41.EmployeeNumber = emp.EmployeeNumber;
            att41.Time = new DateTime(2010, 1, 4, 7, 00, 0);
            att41.ID = _dtCtrl.AddAttendanceRecord(att41);

            AttendanceRecord att42 = new AttendanceRecord();
            att42.EmployeeNumber = emp.EmployeeNumber;
            att42.Time = new DateTime(2010, 1, 4, 18, 0, 0);
            att42.ID = _dtCtrl.AddAttendanceRecord(att42);

            //att5 : expected totalHours: 8.8x
            AttendanceRecord att51 = new AttendanceRecord();
            att51.EmployeeNumber = emp.EmployeeNumber;
            att51.Time = new DateTime(2010, 1, 5, 9, 06, 0);
            att51.ID = _dtCtrl.AddAttendanceRecord(att51);

            AttendanceRecord att52 = new AttendanceRecord();
            att52.EmployeeNumber = emp.EmployeeNumber;
            att52.Time = new DateTime(2010, 1, 5, 18, 2, 0);
            att52.ID = _dtCtrl.AddAttendanceRecord(att52);

            //att6 : expected totalHours: 8.5
            AttendanceRecord att61 = new AttendanceRecord();
            att61.EmployeeNumber = emp.EmployeeNumber;
            att61.Time = new DateTime(2010, 1, 6, 9, 0, 0);
            att61.ID = _dtCtrl.AddAttendanceRecord(att61);

            AttendanceRecord att62 = new AttendanceRecord();
            att62.EmployeeNumber = emp.EmployeeNumber;
            att62.Time = new DateTime(2010, 1, 6, 18, 0, 0);
            att62.ID = _dtCtrl.AddAttendanceRecord(att62);

            AttendanceRecord att63 = new AttendanceRecord();
            att63.EmployeeNumber = emp.EmployeeNumber;
            att63.Time = new DateTime(2010, 1, 6, 12, 30, 0);
            att63.ID = _dtCtrl.AddAttendanceRecord(att63);

            AttendanceRecord att64 = new AttendanceRecord();
            att64.EmployeeNumber = emp.EmployeeNumber;
            att64.Time = new DateTime(2010, 1, 6, 13, 30, 0);
            att64.ID = _dtCtrl.AddAttendanceRecord(att64);
            #endregion
        }
Пример #57
0
        private void BackupDatabase()
        {
            try
            {
                Config config = _dtCtrl.GetConfig();

                if (config.ScheduledBackup)
                {
                    if (config.BackupPeriod == 1 || config.BackupPeriod == 7 && (int)DateTime.Today.DayOfWeek == config.BackupDay)
                    {
                        int timeDiff = Util.CompareTime(config.BackupTime, DateTime.Now);

                        if (timeDiff <= Config.TimeBound) //in allowed range
                        {
                            string fileName = "FaceIDBK" + DateTime.Now.Ticks + ".mdb";

                            if (config.BackupFolder.EndsWith(@"\") == false)
                                config.BackupFolder += @"\";

                            string filePath = config.BackupFolder + fileName;

                            _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;
                            lock (_dtCtrl)
                            {
                                _dtCtrl.BackupDatabase(filePath);
                            }

                            //sleep for 23 hours
                            Thread.Sleep(_timetoSleep3);
                            BackupDatabase();
                        }
                        else //sleep until the right time
                        {
                            if (timeDiff < 0)
                                timeDiff += TimeSpan.FromDays(1).Seconds;

                            Thread.Sleep(Convert.ToInt32(TimeSpan.FromSeconds(timeDiff).TotalMilliseconds));
                            BackupDatabase();
                        }
                    }
                }
            }
            catch
            {
                //TODO
                //Exception: another process is accessing db at the time

                Thread.Sleep(_timeToSleep1);
                BackupDatabase();
            }
        }
Пример #58
0
        private void RemoveEmployeeFromTerminal()
        {
            try
            {
                _dtCtrl = Properties.Settings.Default.IsClient ? RemoteDataController.Instance : LocalDataController.Instance;
                List<UndeletedEmployeeNumber> undelEmployeeNumberList = null;
                lock (_dtCtrl)
                {
                    undelEmployeeNumberList = _dtCtrl.GetUndeletedEmployeeNumberList();
                }

                foreach (UndeletedEmployeeNumber undelEmployeeNumber in undelEmployeeNumberList)
                {
                    Terminal terminal = null;

                    lock (_dtCtrl)
                    {
                        terminal = _dtCtrl.GetTerminal(undelEmployeeNumber.TerminalID);
                    }

                    _terCtrl = new TerminalController();
                    if (_terCtrl.RemoveEmployee(terminal, undelEmployeeNumber.EmployeeNumber))
                    {
                        bool deleted = false;
                        lock (_dtCtrl)
                        {
                            deleted = _dtCtrl.DeleteUndeletedEmployeeNumber(undelEmployeeNumber);
                        }

                        if (deleted == false)
                            throw new Exception();
                    }
                    else
                    {
                        throw new Exception();
                    }
                }

                Thread.Sleep(_timeToSleep2);
                RemoveEmployeeFromTerminal();
            }
            catch
            {
                Thread.Sleep(_timeToSleep1);
                RemoveEmployeeFromTerminal();
            }
        }
Пример #59
0
        private void AddTestOneShiftFlexi(ref IDataController _dtCtrl)
        {
            #region add test company
            Company com = new Company();
            com.Name = DateTime.Now.Ticks.ToString();
            com.ID = _dtCtrl.AddCompany(com);
            #endregion

            #region add test department
            Department dep = new Department();
            dep.CompanyID = com.ID;
            dep.Name = DateTime.Now.Ticks.ToString();
            dep.SupDepartmentID = 0; //root
            dep.ID = _dtCtrl.AddDepartment(dep);
            #endregion

            #region add test working calendar
            List<Break> breakList = new List<Break>();
            Break break1 = new Break();
            break1.From = new DateTime(2000, 2, 2, 12, 0, 0);
            break1.To = new DateTime(2000, 2, 2, 13, 0, 0);
            break1.Name = "break1";
            break1.Paid = true;

            breakList.Add(break1);

            List<Holiday> holidayList = new List<Holiday>();

            PaymentRate workingDayPaymentRate = new PaymentRate();
            workingDayPaymentRate.NumberOfRegularHours = 7;
            workingDayPaymentRate.RegularRate = 100;
            workingDayPaymentRate.NumberOfOvertime1 = 8;
            workingDayPaymentRate.OvertimeRate1 = 200;

            PaymentRate nonWorkingDayPaymentRate = workingDayPaymentRate;
            PaymentRate holidayPaymentRate = workingDayPaymentRate;

            PayPeriod payPeriod = new PayPeriod();
            payPeriod.CustomPeriod = 5;
            payPeriod.PayPeriodTypeID = 5; //custom
            payPeriod.StartFrom = new DateTime(2010, 1, 1);

            WorkingCalendar wCal = new WorkingCalendar();
            wCal.Name = DateTime.Now.Ticks.ToString();
            wCal.ApplyFlexiHours = true;
            wCal.FlexiHours = 40;
            wCal.WeekStartsOn = 3; //Thursday

            List<Shift> shiftList = new List<Shift>();
            Shift shift1 = new Shift();
            shift1.From = new DateTime(2000, 2, 2, 9, 0, 0);
            shift1.To = new DateTime(2000, 2, 2, 18, 0, 0);
            shiftList.Add(shift1);

            wCal.WorkOnMonday = true;
            wCal.WorkOnTuesday = true;
            wCal.WorkOnWednesday = true;
            wCal.WorkOnThursday = true;
            wCal.WorkOnFriday = true;

            wCal.GraceForwardToEntry = 30;
            wCal.GraceBackwardToExit = 30;
            wCal.EarliestBeforeEntry = 60;
            wCal.LastestAfterExit = 180;

            wCal.ID = _dtCtrl.AddWorkingCalendar(wCal, shiftList, new List<Break>(), holidayList, workingDayPaymentRate, nonWorkingDayPaymentRate, holidayPaymentRate, payPeriod);
            #endregion

            #region add test employee
            Employee emp = new Employee();
            emp.Active = true;
            emp.ActiveFrom = DateTime.Today;
            emp.ActiveTo = DateTime.Today.AddDays(1);
            emp.Address = DateTime.Now.Ticks.ToString();
            emp.Birthday = DateTime.Today.AddYears(-20);
            emp.DepartmentID = dep.ID;
            emp.EmployeeNumber = 0;
            emp.FirstName = DateTime.Now.Ticks.ToString();
            emp.JobDescription = DateTime.Now.Ticks.ToString();
            emp.HiredDate = DateTime.Today;
            emp.LeftDate = DateTime.Today.AddYears(1);
            emp.LastName = DateTime.Now.Ticks.ToString();
            emp.PhoneNumber = DateTime.Now.Ticks.ToString();
            emp.WorkingCalendarID = wCal.ID;
            emp.PayrollNumber = _dtCtrl.AddEmployee(emp, new List<Terminal>());
            #endregion

            #region add test att records 2
            //att7 : expected regHour: 10
            AttendanceRecord att71 = new AttendanceRecord();
            att71.EmployeeNumber = emp.EmployeeNumber;
            att71.Time = new DateTime(2010, 1, 7, 9, 0, 0);
            att71.ID = _dtCtrl.AddAttendanceRecord(att71);

            AttendanceRecord att72 = new AttendanceRecord();
            att72.EmployeeNumber = emp.EmployeeNumber;
            att72.Time = new DateTime(2010, 1, 7, 19, 0, 0);
            att72.ID = _dtCtrl.AddAttendanceRecord(att72);

            //att8 : expected regHour: 8
            AttendanceRecord att81 = new AttendanceRecord();
            att81.EmployeeNumber = emp.EmployeeNumber;
            att81.Time = new DateTime(2010, 1, 8, 9, 0, 0);
            att81.ID = _dtCtrl.AddAttendanceRecord(att81);

            AttendanceRecord att82 = new AttendanceRecord();
            att82.EmployeeNumber = emp.EmployeeNumber;
            att82.Time = new DateTime(2010, 1, 8, 17, 0, 0);
            att82.ID = _dtCtrl.AddAttendanceRecord(att82);

            //att9 : expected regHour: 8
            AttendanceRecord att91 = new AttendanceRecord();
            att91.EmployeeNumber = emp.EmployeeNumber;
            att91.Time = new DateTime(2010, 1, 9, 9, 0, 0);
            att91.ID = _dtCtrl.AddAttendanceRecord(att91);

            AttendanceRecord att92 = new AttendanceRecord();
            att92.EmployeeNumber = emp.EmployeeNumber;
            att92.Time = new DateTime(2010, 1, 9, 17, 0, 0);
            att92.ID = _dtCtrl.AddAttendanceRecord(att92);

            //att10 : expected regHour: 8
            AttendanceRecord att101 = new AttendanceRecord();
            att101.EmployeeNumber = emp.EmployeeNumber;
            att101.Time = new DateTime(2010, 1, 10, 9, 00, 0);
            att101.ID = _dtCtrl.AddAttendanceRecord(att101);

            AttendanceRecord att102 = new AttendanceRecord();
            att102.EmployeeNumber = emp.EmployeeNumber;
            att102.Time = new DateTime(2010, 1, 10, 17, 0, 0);
            att102.ID = _dtCtrl.AddAttendanceRecord(att102);

            //att11 : expected regHour: 4
            AttendanceRecord att111 = new AttendanceRecord();
            att111.EmployeeNumber = emp.EmployeeNumber;
            att111.Time = new DateTime(2010, 1, 11, 9, 0, 0);
            att111.ID = _dtCtrl.AddAttendanceRecord(att111);

            AttendanceRecord att112 = new AttendanceRecord();
            att112.EmployeeNumber = emp.EmployeeNumber;
            att112.Time = new DateTime(2010, 1, 11, 13, 0, 0);
            att112.ID = _dtCtrl.AddAttendanceRecord(att112);

            //att12 : expected regHour: 2 overHour: 2
            AttendanceRecord att121 = new AttendanceRecord();
            att121.EmployeeNumber = emp.EmployeeNumber;
            att121.Time = new DateTime(2010, 1, 12, 9, 0, 0);
            att121.ID = _dtCtrl.AddAttendanceRecord(att121);

            AttendanceRecord att122 = new AttendanceRecord();
            att122.EmployeeNumber = emp.EmployeeNumber;
            att122.Time = new DateTime(2010, 1, 12, 13, 0, 0);
            att122.ID = _dtCtrl.AddAttendanceRecord(att122);

            //att13 : expected overHour: 2
            AttendanceRecord att131 = new AttendanceRecord();
            att131.EmployeeNumber = emp.EmployeeNumber;
            att131.Time = new DateTime(2010, 1, 13, 9, 0, 0);
            att131.ID = _dtCtrl.AddAttendanceRecord(att131);

            AttendanceRecord att132 = new AttendanceRecord();
            att132.EmployeeNumber = emp.EmployeeNumber;
            att132.Time = new DateTime(2010, 1, 13, 11, 0, 0);
            att132.ID = _dtCtrl.AddAttendanceRecord(att132);
            #endregion
        }
		public AccessGenericServer(IDataController database)
			: base(database)
		{
		}