public CandleSummary GetCandle(CandleTypes candleType, DateTime tickStart, BasePair pair) { using (var cxt = DataStore.CreateDataStore()) { var data = cxt.Candle.FirstOrDefault(x => x.CandleTypeID == (int)candleType && x.FromTime == tickStart && x.PairID == (int)pair); CandleSummary result = null; if (data != null) { result = ( from c in cxt.Candle join ht in cxt.Tick on c.HighTickID equals ht.TickID join lt in cxt.Tick on c.LowTickID equals lt.TickID join ot in cxt.Tick on c.LowTickID equals ot.TickID join ct in cxt.Tick on c.LowTickID equals ct.TickID where c.CandleID == data.CandleID select new CandleSummary { BasePairID = (int)pair, CandleTypeID = (int)candleType, Close = ct, FromTime = tickStart, High = ht, Low = lt, Open = ot } ).FirstOrDefault(); } return(result); } }
public void Initialize(DateTime fromDate, DateTime toDate, BasePair pair) { this.FromDate = fromDate; this.ToDate = toDate; this.Pair = pair; this.DownloadFilePath = this.BaseDownloadPath + "Zip\\"; }
public FileDownloadStatus SaveFileDownloadStatus(int?fileDownloadStatusID, BasePair pair, string fileName, bool?isCompleted, string dateDesc, bool?isDownloadable, bool?isUnzipped) { using (var cxt = DataStore.CreateDataStore()) { // Check if pair exists first... var cxtPair = cxt.Pair.FirstOrDefault(x => x.PairID == (int)pair); if (cxtPair == null) { cxtPair = Dependency.Dependency.Resolve <IPairManager>().SavePair(pair); } var status = cxt.FileDownloadStatus.FirstOrDefault(x => x.FileDownloadStatusID == fileDownloadStatusID); if (status == null) { status = cxt.GetOrCreateFileDownloadStatus(null); } status.FileName = fileName; status.IsCompleted = isCompleted; status.DateDescription = dateDesc; status.IsDownloadable = isDownloadable; status.PairID = cxtPair.PairID; status.IsUnzipped = isUnzipped; cxt.SubmitChanges(); return(status); } }
public Pair GetPair(BasePair pair) { using (var cxt = DataStore.CreateDataStore()) { var result = cxt.Pair.FirstOrDefault(x => x.PairDescription == pair.ToString()); return(result); } }
public List <double> Sknewness(BasePair basePair, int frameSize, bool cumulative = false) { var result = new List <double>(); if (basePair == BasePair.GC) { var gCount = Content.ToCharArray().Where(x => x.Equals('G')).Count(); var cCount = Content.ToCharArray().Where(x => x.Equals('C')).Count(); var frameCount = Math.Ceiling((double)Content.Length / (double)frameSize); for (int i = 0; i < frameCount; i++) { if (Content.Length - i * frameSize > frameSize) { var tempList = Content.ToList().GetRange(i * frameSize, frameSize); var frameGCount = tempList.Where(x => x.Equals('G')).Count(); var frameCCount = tempList.Where(x => x.Equals('C')).Count(); result.Add(((double)(frameGCount - frameCCount) / (double)(frameGCount + frameCCount))); } } } else { var aCount = Content.ToCharArray().Where(x => x.Equals('A')).Count(); var tCount = Content.ToCharArray().Where(x => x.Equals('T')).Count(); var frameCount = Math.Ceiling((double)Content.Length / (double)frameSize); for (int i = 0; i < frameCount; i++) { if (Content.Length - i * frameSize > frameSize) { var tempList = Content.ToList().GetRange(i * frameSize, frameSize); var frameACount = tempList.Where(x => x.Equals('A')).Count(); var frameTCount = tempList.Where(x => x.Equals('T')).Count(); result.Add(((double)(frameACount - frameTCount) / (double)(frameACount + frameTCount))); } } } if (cumulative) { var cumulativeResult = new List <double>(); for (int i = 0; i < result.Count; i++) { double temp = 0; for (int j = 0; j <= i; j++) { temp += result[j]; } cumulativeResult.Add(temp); } return(cumulativeResult); } return(result); }
public Pair SavePair(BasePair pair) { using (var cxt = DataStore.CreateDataStore()) { var description = pair.ToString(); var cxtPair = cxt.Pair.FirstOrDefault(x => x.PairDescription == description); if (cxtPair == null) { cxtPair = cxt.GetOrCreatePair(null); } cxtPair.PairDescription = description; cxt.SubmitChanges(); return(cxtPair); } }
/// <summary> /// Returns a range of dates depending on the candle type /// </summary> /// <returns></returns> public void CreateCandles(DateTime startDate, DateTime endDate, CandleTypes candleType, BasePair pair) { // We first want to check if all the ticks have been imported this.CheckImportedCSVs(startDate, endDate); // Get the number of minutes to iterate based on the CandleType... var candleTypeSummary = this.GetCandleTypeSummary(candleType); var numberOfMinutesToAdd = candleTypeSummary.NumberOfMinutes; var newStartDate = startDate; while (newStartDate <= endDate) { // Get the starting and ending tick var startTick = newStartDate; var nextTickStart = newStartDate.AddMinutes(numberOfMinutesToAdd); // Check if candle has already been generated or not... var candle = this.GetCandle(candleType, startTick, pair); if (candle != null) { newStartDate = nextTickStart; continue; } // Otherwise create candle var generatedCandle = this.GenerateSingleCandle(candleType, startTick, nextTickStart, pair); if (generatedCandle == null) { newStartDate = nextTickStart; continue; } // Save resulting candle var candleSummary = this.SaveCandle(candleType, startTick, generatedCandle.High.TickID, generatedCandle.Low.TickID, generatedCandle.Open.TickID, generatedCandle.Close.TickID, pair); newStartDate = nextTickStart; } }
public FileDownloadStatus GetFileDownloadStatusUsingDateDescriptionAndBasePair(string dateDesc, BasePair pair) { using (var cxt = DataStore.CreateDataStore()) { var pairDesc = pair.ToString(); //var result = cxt.FileDownloadStatus.FirstOrDefault(x => x.DateDescription == dateDesc && x. == (int)pair); var data = ( from fds in cxt.FileDownloadStatus join p in cxt.Pair on fds.PairID equals p.PairID where p.PairDescription == pairDesc select fds ).FirstOrDefault(); return(data); } }
/// <summary> /// اعمال شیردهی برای برخی از پرسنل /// </summary> /// <param name="MyRule"></param> public void R266(AssignedRule MyRule) { var cnpList = new[] { 2, 3020, 3028, 3501 }; GetLog(MyRule, " Before Execute State:", cnpList); if ( this.Person.GetShiftByDate(this.RuleCalculateDate).Value > 0 && this.DoConcept(1).Value > 0 && // مفدار غیبت مجاز برای شیردهی !string.IsNullOrEmpty(this.Person.PersonTASpec.R4) && Utility.ToInteger(this.Person.PersonTASpec.R4) > 0 && // تاریخ شروع غیبت مجاز برای شیردهی !string.IsNullOrEmpty(this.Person.PersonTASpec.R5) && // تاریخ پایان غیبت مجاز برای شیردهی !string.IsNullOrEmpty(this.Person.PersonTASpec.R6) && this.DoConcept(3028).Value > 0 ) { if ( PersianDateTime.Parse(this.Person.PersonTASpec.R5).GregorianDate.Date <= this.RuleCalculateDate && this.RuleCalculateDate <= PersianDateTime.Parse(this.Person.PersonTASpec.R6).GregorianDate.Date ) { var minutes = Utility.ToInteger(this.Person.PersonTASpec.R4); foreach (IPair pair in ((PairableScndCnpValue)this.DoConcept(3028)).Pairs.OrderBy(x => x.From)) { if (pair.Value > minutes) { IPair tempPair = new BasePair(pair.To - minutes, pair.To); this.DoConcept(3020).Value += tempPair.Value; var hh = Operation.Differance(this.DoConcept(3028), tempPair); ((PairableScndCnpValue)this.DoConcept(3028)).AddPairs(hh.Pairs); // غيبت ساعتي مجاز شيردهي ((PairableScndCnpValue)this.DoConcept(3501)).AddPair(tempPair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(tempPair); pair.To -= minutes; break; } if (pair.Value == minutes) { this.DoConcept(3020).Value += pair.Value; ((PairableScndCnpValue)this.DoConcept(3028)).RemovePair(pair); // غيبت ساعتي مجاز شيردهي ((PairableScndCnpValue)this.DoConcept(3501)).AddPair(pair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(pair); pair.From = pair.To = 0; break; } this.DoConcept(3020).Value += pair.Value; minutes -= pair.Value; ((PairableScndCnpValue)this.DoConcept(3028)).RemovePair(pair); // غيبت ساعتي مجاز شيردهي ((PairableScndCnpValue)this.DoConcept(3501)).AddPair(pair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(pair); pair.From = pair.To = 0; } } } GetLog(MyRule, " After Execute State:", cnpList); }
public void AddBasePair(BasePair bp) { basePairs.Add(bp); }
/// <summary> جانبازی</summary> /// <remarks></remarks> //اضافه کار مجاز4002 public virtual void R6599(AssignedRule MyRule) { var conceptList = new[] { 2, 3, 13, 4005, 4006, 4007, 5501, 3020, 3028, 4002, 3029, 3030, 3031 }; GetLog(MyRule, DebugRuleState.Before, conceptList); //4002 اضافه کارساعتي مجاز //3028 غیبت ساعتی غیر مجاز //3029 غیبت ساعتی مجاز if ( this.Person.GetShiftByDate(this.RuleCalculateDate).Value > 0 && this.DoConcept(1).Value > 0 && this.Person.PersonTASpec.R16 > 0 && !Utility.IsEmpty(this.Person.PersonTASpec.R16Value.ComboValue) && Utility.ToInteger(this.Person.PersonTASpec.R16Value.ComboValue) > 0 && this.Person.PersonTASpec.R16Value.ComboValue.Length.Equals(3) ) { var percentMinute = new Dictionary <string, int> { { "25", 45 }, { "30", 60 }, { "40", 90 }, { "50", 120 }, { "60", 150 }, { "70", 210 } }; var percent = this.Person.PersonTASpec.R16Value.ComboValue.Substring(0, 2); if (percentMinute.ContainsKey(percent)) { var minutes = percentMinute.FirstOrDefault(x => x.Key == percent).Value; bool doOnOvertime = this.Person.PersonTASpec.R16Value.ComboValue.Substring(2, 1) == "1"; if (doOnOvertime) { #region OLD // اعمال روی اضافه کار //((PairableScndCnpValue)this.DoConcept(4002)).IncreaseValueEx(minutes); //var basePair = new BasePair( // ((PairableScndCnpValue)this.DoConcept(4002)).Pairs.OrderBy(x => x.To).Last().To - minutes, // ((PairableScndCnpValue)this.DoConcept(4002)).Pairs.OrderBy(x => x.To).Last().To // ); #endregion BasePair basePair = null; if (this.DoConcept(4002).Value > 0) { basePair = new BasePair( ((PairableScndCnpValue)this.DoConcept(4002)).Pairs.OrderBy(x => x.To).First().To, ((PairableScndCnpValue)this.DoConcept(4002)).Pairs.OrderBy(x => x.To).First().To + minutes ); } else { basePair = new BasePair( this.Person.GetShiftByDate(this.RuleCalculateDate).Pairs.OrderBy(x => x.To).First().To, this.Person.GetShiftByDate(this.RuleCalculateDate).Pairs.OrderBy(x => x.To).First().To + minutes ); } // قرار شد در غيبت نمايش داده نشود //this.DoConcept(5501).Value += minutes; ((PairableScndCnpValue)this.DoConcept(5501)).AddPair(basePair); this.ReCalculate(3, 13, 4005, 4006, 4007); } else { // اعمال روی غیبت if (this.DoConcept(3028).Value > 0) { foreach (IPair pair in ((PairableScndCnpValue)this.DoConcept(3028)).Pairs.OrderByDescending(x => x.From)) { if (pair.Value > minutes) { IPair tempPair = new BasePair(pair.To - minutes, pair.To); this.DoConcept(3020).Value += tempPair.Value; var pairableScndCnpValue = Operation.Differance(this.DoConcept(3028), tempPair); ((PairableScndCnpValue)this.DoConcept(3028)).AddPairs(pairableScndCnpValue.Pairs); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(tempPair); pair.To -= minutes; break; } if (pair.Value == minutes) { this.DoConcept(3020).Value += pair.Value; ((PairableScndCnpValue)this.DoConcept(3028)).RemovePair(pair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(pair); pair.From = pair.To = 0; break; } this.DoConcept(3020).Value += pair.Value; minutes -= pair.Value; ((PairableScndCnpValue)this.DoConcept(3028)).RemovePair(pair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(pair); pair.From = pair.To = 0; } } } } ((PairableScndCnpValue)this.DoConcept(3029)).AddPairs(Operation.Intersect(this.DoConcept(3029), this.DoConcept(3028))); ((PairableScndCnpValue)this.DoConcept(3030)).AddPairs(Operation.Intersect(this.DoConcept(3030), this.DoConcept(3028))); ((PairableScndCnpValue)this.DoConcept(3031)).AddPairs(Operation.Intersect(this.DoConcept(3031), this.DoConcept(3028))); } GetLog(MyRule, DebugRuleState.Before, conceptList); }
/// <summary> /// کسر تقلیل /// </summary> /// <param name="MyRule"></param> public override void R5023(AssignedRule MyRule) { //1082 مجموع انواع مرخصی ساعتی //2023 مفهوم مجموع ماموريت ساعتي //3044 غيبت ساعتي مجاز تقليل GetLog(MyRule, DebugRuleState.Before, 2, 3, 13, 3020, 3028, 3044, 4002, 4005, 4006, 4007); this.DoConcept(1082); this.DoConcept(2023); var personParam = this.Person.PersonTASpec.GetParamValue(this.Person.ID, "kasre_taghlil", this.RuleCalculateDate); if ( this.Person.GetShiftByDate(this.RuleCalculateDate).Value > 0 && this.DoConcept(1).Value > 0 && // مفدار غیبت مجاز برای تقلیل this.Person.GetShiftByDate(this.RuleCalculateDate).Value > 0 && this.DoConcept(1).Value > 0 && personParam != null ) { var minutes = Utility.ToInteger(personParam.Value); if (MyRule["First", this.RuleCalculateDate].ToInt() == 1) { IPair takhir = ((PairableScndCnpValue)this.DoConcept(3028)).Pairs.OrderBy(x => x.From).FirstOrDefault(); IPair tagil = ((PairableScndCnpValue)this.DoConcept(3028)).Pairs.OrderBy(x => x.From).LastOrDefault(); IPair tempPair = null; #region اعمال روی غیبت if (takhir != null && takhir.Value > 0) { if (takhir.Value >= minutes) { tempPair = new BasePair(takhir.From, takhir.From + minutes); } else { tempPair = takhir; } } else if (tagil != null && tagil.Value > 0) { if (tagil.Value >= minutes) { tempPair = new BasePair(tagil.To - minutes, tagil.To); } else { tempPair = tagil; } } if (tempPair != null && tempPair.Value > 0) { this.DoConcept(3020).Value += tempPair.Value; var pairableScndCnpValue = Operation.Differance(this.DoConcept(3028), tempPair); ((PairableScndCnpValue)this.DoConcept(3028)).AddPairs(pairableScndCnpValue.Pairs); // غيبت ساعتي مجاز تقليل ((PairableScndCnpValue)this.DoConcept(3044)).AppendPair(tempPair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(tempPair); } #endregion } if (MyRule["Second", this.RuleCalculateDate].ToInt() == 1) { #region اعمال روی اضافه کار if (minutes > 0) { // اعمال روی اضافه کار ((PairableScndCnpValue)this.DoConcept(4002)).IncreaseValueEx(minutes); var basePair = new BasePair( ((PairableScndCnpValue)this.DoConcept(4002)).Pairs.OrderBy(x => x.To).Last().To - minutes, ((PairableScndCnpValue)this.DoConcept(4002)).Pairs.OrderBy(x => x.To).Last().To ); // غيبت ساعتي مجاز تقليل ((PairableScndCnpValue)this.DoConcept(3044)).AddPair(basePair); this.ReCalculate(3, 13, 4005, 4006, 4007); } #endregion } } GetLog(MyRule, DebugRuleState.After, 2, 3, 13, 3020, 3028, 3044, 4002, 4005, 4006, 4007); }
/// <summary> /// شیردهی /// </summary> /// <param name="MyRule"></param> //public override void R5021(AssignedRule MyRule) //{ // //3020 غیبت ساعتی مجاز // //3029 تاخیر // //3030 تعجیل // //3028 غیبت ساعتی // //3021 تاخیر مجاز // //3022 تعجیل مجاز // //3040 غیبت مجاز شیردهی // //1082 مجموع انواع مرخصی ساعتی // //2023 مفهوم مجموع ماموريت ساعتي // var conceptList = new[] { 2, 3020, 3028, 3040 }; // GetLog(MyRule, " Before Execute State:", conceptList); // this.DoConcept(1082); // this.DoConcept(2023); // var personParam_takhir = this.Person.PersonTASpec.GetParamValue(this.Person.ID, "kasre_shirdehi_takhir", this.RuleCalculateDate); // var personParam_tajil = this.Person.PersonTASpec.GetParamValue(this.Person.ID, "kasre_shirdehi_tajil", this.RuleCalculateDate); // if ( // this.Person.GetShiftByDate(this.RuleCalculateDate).Value > 0 && // this.DoConcept(1).Value > 0 && // (personParam_takhir != null || personParam_tajil != null) && // this.DoConcept(3028).Value > 0 // ) // { // var minutes_takhir = personParam_takhir != null ? Utility.ToInteger(personParam_takhir.Value) : 0; // var minutes_tajil = personParam_tajil != null ? Utility.ToInteger(personParam_tajil.Value) : 0; // IPair takhir = ((PairableScndCnpValue)this.DoConcept(3028)).Pairs.OrderBy(x => x.From).FirstOrDefault(); // IPair tagil = ((PairableScndCnpValue)this.DoConcept(3028)).Pairs.OrderBy(x => x.From).LastOrDefault(); // IPair tempPair = null; // if (takhir != null && takhir.Value > 0 && minutes_takhir>0) // { // if (takhir.Value >= minutes_takhir) // { // tempPair = new BasePair(takhir.From, takhir.From + minutes_takhir); // } // else // { // tempPair = takhir; // } // } // else if (tagil != null && tagil.Value > 0 && minutes_tajil > 0) // { // if (tagil.Value >= minutes_tajil) // { // tempPair = new BasePair(tagil.To - minutes_tajil, tagil.To); // } // else // { // tempPair = tagil; // } // } // if (tempPair != null && tempPair.Value > 0) // { // this.DoConcept(3020).Value += tempPair.Value; // var pairableScndCnpValue = Operation.Differance(this.DoConcept(3028), tempPair); // ((PairableScndCnpValue)this.DoConcept(3028)).AddPairs(pairableScndCnpValue.Pairs); // // غيبت ساعتي مجاز شيردهي // ((PairableScndCnpValue)this.DoConcept(3040)).AddPair(tempPair); // ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(tempPair); // } // } // GetLog(MyRule, " After Execute State:", conceptList); //} /// <summary> /// کسر مهد /// </summary> /// <param name="MyRule"></param> public override void R5022(AssignedRule MyRule) { //2 کارکردخالص ساعتی //3020 غیبت ساعتی مجاز //3028 غیبت ساعتی غیرمجاز //3042 غیبت مجاز مهد //1082 مجموع انواع مرخصی ساعتی //1056 مرخصی بی حقوق 12 //2023 مفهوم مجموع ماموريت ساعتي //3029 تاخیر //3030تعجیل GetLog(MyRule, DebugRuleState.Before, 1082, 1056, 2023, 2, 3042, 3020, 3028, 3029, 3030); this.DoConcept(1082); this.DoConcept(1056); this.DoConcept(2023); var personParam_takhir = this.Person.PersonTASpec.GetParamValue(this.Person.ID, "kasre_mahd_takhir", this.RuleCalculateDate); var personParam_tajil = this.Person.PersonTASpec.GetParamValue(this.Person.ID, "kasre_mahd_tajil", this.RuleCalculateDate); if ( this.Person.GetShiftByDate(this.RuleCalculateDate).Value > 0 && this.DoConcept(1).Value > 0 && (personParam_takhir != null || personParam_tajil != null) && this.DoConcept(3028).Value > 0 ) { int startOfShift = this.Person.GetShiftByDate(this.RuleCalculateDate).Pairs.OrderBy(x => x.From).First().From; int endOfShift = this.Person.GetShiftByDate(this.RuleCalculateDate).Pairs.OrderBy(x => x.From).Last().To; var minutes_takhir = personParam_takhir != null?Utility.ToInteger(personParam_takhir.Value) : 0; var minutes_tajil = personParam_tajil != null?Utility.ToInteger(personParam_tajil.Value) : 0; //IPair takhir = ((PairableScndCnpValue)this.DoConcept(3028)).Pairs.Where(x=>x.From==startOfShift) .OrderBy(x => x.From).FirstOrDefault(); //IPair tagil = ((PairableScndCnpValue)this.DoConcept(3028)).Pairs.Where(x => x.To == endOfShift).OrderBy(x => x.From).LastOrDefault(); IPair takhir = ((PairableScndCnpValue)this.DoConcept(3029)).Pairs.OrderBy(x => x.From).FirstOrDefault(); IPair tagil = ((PairableScndCnpValue)this.DoConcept(3030)).Pairs.OrderBy(x => x.From).LastOrDefault(); IPair tempPair = null; if (takhir != null && takhir.Value > 0 && takhir.Value <= minutes_takhir) { if (takhir.Value >= minutes_takhir) { tempPair = new BasePair(takhir.From, takhir.From + minutes_takhir); } else { tempPair = takhir; } } else if (tagil != null && tagil.Value > 0 && tagil.Value <= minutes_tajil) { if (tagil.Value >= minutes_tajil) { tempPair = new BasePair(tagil.To - minutes_tajil, tagil.To); } else { tempPair = tagil; } } if (tempPair != null && tempPair.Value > 0) { this.DoConcept(3020).Value += tempPair.Value; var pairableScndCnpValue = Operation.Differance(this.DoConcept(3028), tempPair); ((PairableScndCnpValue)this.DoConcept(3028)).AddPairs(pairableScndCnpValue.Pairs); pairableScndCnpValue = Operation.Differance(this.DoConcept(3029), tempPair); ((PairableScndCnpValue)this.DoConcept(3029)).AddPairs(pairableScndCnpValue.Pairs); pairableScndCnpValue = Operation.Differance(this.DoConcept(3030), tempPair); ((PairableScndCnpValue)this.DoConcept(3030)).AddPairs(pairableScndCnpValue.Pairs); // غيبت ساعتي مجاز مهد ((PairableScndCnpValue)this.DoConcept(3042)).AddPair(tempPair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(tempPair); } } GetLog(MyRule, DebugRuleState.After, 1082, 1056, 2023, 2, 3042, 3020, 3028, 3029, 3030); }
/// <summary> /// اعمال کسر تقلیل برای برخی از پرسنل /// </summary> /// <param name="MyRule"></param> public override void R5021(AssignedRule MyRule) { //1082 مجموع انواع مرخصی ساعتی //2023 مفهوم مجموع ماموريت ساعتي var conceptList = new[] { 2, 3, 13, 3020, 3028, 3040, 4002, 4005, 4006, 4007, 1119 }; GetLog(MyRule, DebugRuleState.Before, conceptList); this.DoConcept(1082); this.DoConcept(2023); var personParam = this.Person.PersonTASpec.GetParamValue(this.Person.ID, "kasre_shirdehi", this.RuleCalculateDate); if ( this.Person.GetShiftByDate(this.RuleCalculateDate).Value > 0 && this.DoConcept(1).Value > 0 && // مفدار غیبت مجاز برای تقلیل this.Person.GetShiftByDate(this.RuleCalculateDate).Value > 0 && this.DoConcept(1).Value > 0 && personParam != null ) { var minutes = Utility.ToInteger(personParam.Value); if (MyRule["Second", this.RuleCalculateDate].ToInt() == 1) { #region اعمال روی غیبت if (this.DoConcept(3028).Value > 0) { while (this.DoConcept(3028).Value > 0 && minutes > 0) { foreach (IPair pair in ((PairableScndCnpValue)this.DoConcept(3028)).Pairs.OrderBy(x => x.From)) { if (pair.Value > minutes) { IPair tempPair = new BasePair(pair.To - minutes, pair.To); this.DoConcept(3020).Value += tempPair.Value; var PairableScndCnpValue = Operation.Differance(this.DoConcept(3028), tempPair); ((PairableScndCnpValue)this.DoConcept(3028)).AddPairs(PairableScndCnpValue.Pairs); // غيبت ساعتي مجاز تقليل ((PairableScndCnpValue)this.DoConcept(3040)).AppendPair(tempPair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(tempPair); pair.To -= minutes; minutes = 0; break; } if (pair.Value == minutes) { this.DoConcept(3020).Value += pair.Value; minutes -= pair.Value; ((PairableScndCnpValue)this.DoConcept(3028)).RemovePair(pair); // غيبت ساعتي مجاز تقليل ((PairableScndCnpValue)this.DoConcept(3040)).AppendPair(pair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(pair); pair.From = pair.To = 0; break; } if (pair.Value < minutes) { this.DoConcept(3020).Value += pair.Value; minutes -= pair.Value; ((PairableScndCnpValue)this.DoConcept(3028)).RemovePair(pair); // غيبت ساعتي مجاز تقليل ((PairableScndCnpValue)this.DoConcept(3040)).AddPair(pair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(pair); pair.From = pair.To = 0; } } } } #endregion } if (MyRule["First", this.RuleCalculateDate].ToInt() == 1) { #region اعمال روی اضافه کار if (minutes > 0) { // اعمال روی اضافه کار ((PairableScndCnpValue)this.DoConcept(4002)).IncreaseValueEx(minutes); var basePair = new BasePair( ((PairableScndCnpValue)this.DoConcept(4002)).Pairs.OrderBy(x => x.To).Last().To - minutes, ((PairableScndCnpValue)this.DoConcept(4002)).Pairs.OrderBy(x => x.To).Last().To ); // غيبت ساعتي مجاز تقليل ((PairableScndCnpValue)this.DoConcept(3040)).AddPair(basePair); this.ReCalculate(3, 13, 4005, 4006, 4007); } #endregion } if (MyRule.HasParameter("Third", this.RuleCalculateDate)) { if (MyRule["Third", this.RuleCalculateDate].ToInt() == 1) { #region اعمال روی مرخصی if (minutes > 0) { // اعمال روی مرخصی this.Person.AddBudgetLeave(this.RuleCalculateDate, minutes); this.DoConcept(1119).Value = minutes; } #endregion } } } GetLog(MyRule, DebugRuleState.After, conceptList); }
void RenderHelix() { float length = lengthInPI * Mathf.PI; float step = 0.05f; int npos = (int)(length / step); Vector3[] positionsBlue = new Vector3[npos]; Vector3[] positionsRed = new Vector3[npos]; // Make the strands. for (int i = 0; i < npos; i++) { float t = step * i; positionsBlue[i] = curve.Ft(t); positionsRed[i] = curve.Ft(t, Mathf.PI); } tubeRendererBlue.SetPositions(positionsBlue); tubeRendererRed.SetPositions(positionsRed); // Set tube colliders. if (Application.isPlaying) { tubeRendererBlue.gameObject.GetComponent <MeshCollider>().sharedMesh = tubeRendererBlue.gameObject.GetComponent <MeshFilter>().mesh; tubeRendererRed.gameObject.GetComponent <MeshCollider>().sharedMesh = tubeRendererRed.gameObject.GetComponent <MeshFilter>().mesh; } // Make the base pairs. Each pair has the same x value. float pairStep = 0.75f; int npairs = (int)(length / pairStep); for (float x = 0; x < length; x += pairStep) { Vector3[] positions = { curve.Ft(x), curve.Ft(x, Mathf.PI) }; Vector3 direction = positions[1] - positions[0]; float r = Random.Range(0f, 1f); GameObject pf; if (r > 0.5f) { pf = pairPrefab; } else { pf = pairPrefab2; } GameObject tb = Instantiate(pf, positions[1], Quaternion.LookRotation(direction, Vector3.up), transform); tb.transform.localScale = new Vector3(tb.transform.localScale.x, tb.transform.localScale.y, direction.magnitude); // Add to game state. BasePair basePair = tb.GetComponent <BasePair>(); if (gameState != null) { gameState.AddBasePair(basePair); } } // Make barrier proteins Vector3[] positions2 = { curve.Ft(minClamp * Mathf.PI), curve.Ft(minClamp * Mathf.PI, Mathf.PI), curve.Ft(maxClamp * Mathf.PI), curve.Ft(maxClamp * Mathf.PI, Mathf.PI) }; Vector3 direction1 = positions2[1] - positions2[0]; Vector3 direction2 = positions2[3] - positions2[2]; GameObject bp1 = Instantiate(barrierProtein, positions2[0], Quaternion.LookRotation(direction1, Vector3.up), transform); GameObject bp2 = Instantiate(barrierProtein, positions2[1], Quaternion.LookRotation(-1 * direction1, Vector3.up), transform); GameObject bp3 = Instantiate(barrierProtein, positions2[2], Quaternion.LookRotation(direction2, Vector3.up), transform); GameObject bp4 = Instantiate(barrierProtein, positions2[3], Quaternion.LookRotation(-1 * direction2, Vector3.up), transform); }
public CandleSummary SaveCandle(CandleTypes candleType, DateTime fromTime, int highTickID, int lowTickID, int openTickID, int closeTickID, BasePair pair) { using (var cxt = DataStore.CreateDataStore()) { // At this point, we will just assume that candle we will be saving is always new... var candle = cxt.GetOrCreateCandle(null); candle.CandleTypeID = (int)candleType; candle.FromTime = fromTime; candle.HighTickID = highTickID; candle.LowTickID = lowTickID; candle.OpenTickID = openTickID; candle.CloseTickID = closeTickID; candle.PairID = (int)pair; cxt.SubmitChanges(); return(this.GetCandle(candleType, candle.FromTime, pair)); } }
/// <summary> /// Gets a single candle of a DateTime range /// </summary> /// <param name="candleType"></param> /// <param name="tickStart"></param> /// <param name="nextTickStart"></param> /// <param name="pair"></param> /// <returns></returns> public CandleSummary GenerateSingleCandle(CandleTypes candleType, DateTime tickStart, DateTime nextTickStart, BasePair pair) { CandleSummary result = null; using (var cxt = DataStore.CreateDataStore()) { var data = ( from t in cxt.Tick join p in cxt.Pair on t.PairID equals p.PairID where p.PairID == (int)pair && t.TickTime >= tickStart && t.TickTime < nextTickStart select t ).OrderBy(x => x.TickTime).ToList(); if (data.Count > 0) { result = new CandleSummary(); result.High = data.Aggregate((x, y) => x.Bid > y.Bid ? x : y); result.Low = data.Aggregate((x, y) => x.Bid < y.Bid ? x : y); result.Open = data.FirstOrDefault(); result.Close = data.LastOrDefault(); result.FromTime = tickStart; result.ToTime = nextTickStart; result.BasePairID = (int)pair; result.CandleTypeID = (int)candleType; } return(result); } }
public CandleGenerator(DateTime dateStart, DateTime dateEnd, CandleTypes candleType, BasePair pair) { this.DateStart = dateStart; this.DateEnd = dateEnd; this.CandleType = candleType; this.Pair = pair; }
public override string ToString() { return(BasePair.ToString()); }
/// <summary> /// اعمال کسر تقلیل برای برخی از پرسنل /// </summary> /// <param name="MyRule"></param> public void R268(AssignedRule MyRule) { var cnpList = new[] { 2, 3, 13, 3020, 3028, 3505, 4002, 4005, 4006, 4007 }; GetLog(MyRule, " Before Execute State:", cnpList); if ( this.Person.GetShiftByDate(this.RuleCalculateDate).Value > 0 && this.DoConcept(1).Value > 0 && // مفدار غیبت مجاز برای تقلیل !string.IsNullOrEmpty(this.Person.PersonTASpec.R7) && Utility.ToInteger(this.Person.PersonTASpec.R7) > 0 && // تاریخ شروع غیبت مجاز برای تقلیل !string.IsNullOrEmpty(this.Person.PersonTASpec.R8) && // تاریخ پایان غیبت مجاز برای تقلیل !string.IsNullOrEmpty(this.Person.PersonTASpec.R9) ) { if ( PersianDateTime.Parse(this.Person.PersonTASpec.R8).GregorianDate.Date <= this.RuleCalculateDate && this.RuleCalculateDate <= PersianDateTime.Parse(this.Person.PersonTASpec.R9).GregorianDate.Date ) { var minutes = Utility.ToInteger(this.Person.PersonTASpec.R7); if (MyRule["First", this.RuleCalculateDate].ToInt() == 1) { #region اعمال روی غیبت if (this.DoConcept(3028).Value > 0) { while (this.DoConcept(3028).Value > 0 && minutes > 0) { foreach (IPair pair in ((PairableScndCnpValue)this.DoConcept(3028)).Pairs.OrderBy(x => x.From)) { if (pair.Value > minutes) { IPair tempPair = new BasePair(pair.To - minutes, pair.To); this.DoConcept(3020).Value += tempPair.Value; var hh = Operation.Differance(this.DoConcept(3028), tempPair); ((PairableScndCnpValue)this.DoConcept(3028)).AddPairs(hh.Pairs); // غيبت ساعتي مجاز تقليل ((PairableScndCnpValue)this.DoConcept(3505)).AddPair(tempPair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(tempPair); pair.To -= minutes; minutes = 0; break; } if (pair.Value == minutes) { this.DoConcept(3020).Value += pair.Value; minutes -= pair.Value; ((PairableScndCnpValue)this.DoConcept(3028)).RemovePair(pair); // غيبت ساعتي مجاز تقليل ((PairableScndCnpValue)this.DoConcept(3505)).AddPair(pair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(pair); pair.From = pair.To = 0; break; } if (pair.Value < minutes) { this.DoConcept(3020).Value += pair.Value; minutes -= pair.Value; ((PairableScndCnpValue)this.DoConcept(3028)).RemovePair(pair); // غيبت ساعتي مجاز تقليل ((PairableScndCnpValue)this.DoConcept(3505)).AddPair(pair); ((PairableScndCnpValue)this.DoConcept(2)).AppendPair(pair); pair.From = pair.To = 0; } } } } #endregion } if (MyRule["Second", this.RuleCalculateDate].ToInt() == 1) { #region اعمال روی اضافه کار if (minutes > 0) { // اعمال روی اضافه کار ((PairableScndCnpValue)this.DoConcept(4002)).IncreaseValue(minutes); var bb = new BasePair( ((PairableScndCnpValue)this.DoConcept(4002)).Pairs.OrderBy(x => x.To).Last().To - minutes, ((PairableScndCnpValue)this.DoConcept(4002)).Pairs.OrderBy(x => x.To).Last().To ); // غيبت ساعتي مجاز تقليل ((PairableScndCnpValue)this.DoConcept(3505)).AddPair(bb); this.ReCalculate(3, 13, 4005, 4006, 4007); } #endregion } } } GetLog(MyRule, " After Execute State:", cnpList); }