Exemplo n.º 1
0
        public double GetUserBasedTiming(int wpm, TimingType path)
        {
            double total = 0;
            List <LinkedQuestion> list;

            if (path == TimingType.Max)
            {
                list = UserQuestionsMax;
            }
            else if (path == TimingType.Min)
            {
                list = UserQuestionsMin;
            }
            else
            {
                list = UserQuestions;
            }

            foreach (LinkedQuestion q in list)
            {
                if (q.GetQnumValue() >= StartQ && IsForTiming(q))
                {
                    total += q.GetTiming(wpm, false, IncludeNotes);
                }
            }

            total = (double)total / 60;

            return(total);
        }
Exemplo n.º 2
0
        public int TotalWordCount(TimingType path)
        {
            int totalWords = 0;

            List <LinkedQuestion> list;

            if (path == TimingType.Max)
            {
                list = UserQuestionsMax;
            }
            else if (path == TimingType.Min)
            {
                list = UserQuestionsMin;
            }
            else
            {
                list = UserQuestions;
            }

            foreach (LinkedQuestion q in list)
            {
                if (q.GetQnumValue() >= StartQ && IsForTiming(q))
                {
                    totalWords += q.WordCount(false);
                }
            }

            return(totalWords);
        }
Exemplo n.º 3
0
	void cycleThroughExamples(){
		if(exampleIter==0){
			int iter = (int)timingType + 1;
			if(iter>(int)TimingType.Length)
				iter = 0;
			timingType = (TimingType)iter;
			useEstimatedTime = timingType==TimingType.IgnoreTimeScale;
			Time.timeScale = useEstimatedTime ? 0 : 1f; // pause the Time Scale to show the effectiveness of the useEstimatedTime feature (this is very usefull with Pause Screens)
			if(timingType==TimingType.HalfTimeScale)
				Time.timeScale = 0.5f;

			if(timingType==TimingType.VariableTimeScale){
				descrTimeScaleChangeId = LeanTween.value( gameObject, 0.01f, 10.0f, 3f).setOnUpdate( (float val)=>{
					//Debug.Log("timeScale val:"+val);
					Time.timeScale = val;
				}).setEase(LeanTweenType.easeInQuad).setUseEstimatedTime(true).setRepeat(-1).id;
			}else{
				Debug.Log("cancel variable time");
				LeanTween.cancel( descrTimeScaleChangeId );
			}
		}
		gameObject.BroadcastMessage( exampleFunctions[ exampleIter ] );

		// Debug.Log("cycleThroughExamples time:"+Time.time + " useEstimatedTime:"+useEstimatedTime);
		float delayTime = 1.1f;
		LeanTween.delayedCall( gameObject, delayTime, cycleThroughExamples).setUseEstimatedTime(useEstimatedTime);

		exampleIter = exampleIter+1>=exampleFunctions.Length ? 0 : exampleIter + 1;
	}
Exemplo n.º 4
0
        /// <summary>
        /// Calculates the WPM needed to read all the questions in the given amount of time.
        /// </summary>
        /// <param name="targetTime"></param>
        /// <returns></returns>
        public double GetTargetWPMUserBased(double targetTime, TimingType path)
        {
            double targetWPM  = 0;
            double totalWords = 0;

            List <LinkedQuestion> list;

            if (path == TimingType.Max)
            {
                list = UserQuestionsMax;
            }
            else if (path == TimingType.Min)
            {
                list = UserQuestionsMin;
            }
            else
            {
                list = UserQuestions;
            }

            foreach (LinkedQuestion q in list)
            {
                if (q.GetQnumValue() >= StartQ && IsForTiming(q))
                {
                    totalWords += q.WordCount();
                }
            }

            targetWPM = (double)(totalWords / (targetTime * 60)) * 60;

            return(targetWPM);
        }
Exemplo n.º 5
0
    private void _PlaySound(TimingType currentTime)
    {
        if (currentTime != playTiming)
        {
            return;
        }

        SoundManager.PlaySound(AudioClip, volume, transform.position);
    }
Exemplo n.º 6
0
 public CoincidenceEG(DetectionSystem parent, string newName, uint id) : base(parent, newName, id)
 {
     eventGeneratorType = "Coincidence";
     coincidenceType    = CoincidenceType.A_THEN_B;
     timingType         = TimingType.START_TO_END;
     eventGeneratorA    = null;
     eventGeneratorB    = null;
     window             = TimeSpan.FromTicks(0);
     minDifference      = TimeSpan.FromTicks(0);
 }
Exemplo n.º 7
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            user1 = (Respondent)cboUser1.SelectedItem;
            user2 = (Respondent)cboUser2.SelectedItem;

            user1Path    = (TimingType)cboUser1Path.SelectedItem;
            user2Path    = (TimingType)cboUser2Path.SelectedItem;
            DialogResult = DialogResult.OK;
            Close();
        }
Exemplo n.º 8
0
 public Data(string name, string summary, int sprite, string[] conditions, string[] results, string range, TimingType timing)
 {
     Name = name;
     Summary = summary;
     SpriteNumber = sprite;
     Conditions = conditions;
     Result = results;
     Range = range;
     Timing = timing;
 }
Exemplo n.º 9
0
 public CoincidenceEG(DetectionSystem parent, string newName, CoincidenceType newCoincidenceType, TimingType newTimingType, uint id) : base(parent, newName, id)
 {
     eventGeneratorType = "Coincidence";
     coincidenceType    = newCoincidenceType;
     timingType         = newTimingType;
     eventGeneratorA    = null;
     eventGeneratorB    = null;
     window             = TimeSpan.FromTicks(0);
     minDifference      = TimeSpan.FromTicks(0);
 }
Exemplo n.º 10
0
    void cycleThroughExamples()
    {
        if (exampleIter == 0)
        {
            int iter = (int)timingType + 1;
            if (iter > (int)TimingType.Length)
            {
                iter = 0;
            }
            timingType       = (TimingType)iter;
            useEstimatedTime = timingType == TimingType.IgnoreTimeScale;
            Time.timeScale   =
                useEstimatedTime
                    ? 0
                    : 1f; // pause the Time Scale to show the effectiveness of the useEstimatedTime feature (this is very usefull with Pause Screens)
            if (timingType == TimingType.HalfTimeScale)
            {
                Time.timeScale = 0.5f;
            }

            if (timingType == TimingType.VariableTimeScale)
            {
                descrTimeScaleChangeId = LeanTween.value(gameObject, 0.01f, 10.0f, 3f).setOnUpdate((float val) =>
                {
                    //Debug.Log("timeScale val:"+val);
                    Time.timeScale = val;
                }).setEase(LeanTweenType.easeInQuad).setUseEstimatedTime(true).setRepeat(-1).id;
            }
            else
            {
                Debug.Log("cancel variable time");
                LeanTween.cancel(descrTimeScaleChangeId);
            }
        }

        gameObject.BroadcastMessage(exampleFunctions[exampleIter]);

        // Debug.Log("cycleThroughExamples time:"+Time.time + " useEstimatedTime:"+useEstimatedTime);
        float delayTime = 1.1f;

        LeanTween.delayedCall(gameObject, delayTime, cycleThroughExamples).setUseEstimatedTime(useEstimatedTime);

        exampleIter = exampleIter + 1 >= exampleFunctions.Length ? 0 : exampleIter + 1;
    }
        private string[] getOWCSchema2()
        {
            string[] rows    = TimingType.ParserAttributeTimingType(this.rblTimingType.SelectedValue);
            string[] columns = SummaryTarget.ParserAttributeSummaryTarget2(this.rblSummaryTarget.SelectedValue);

            ArrayList schemaList = new ArrayList();

            foreach (string row in rows)
            {
                schemaList.Add(row);
            }
            foreach (string column in columns)
            {
                schemaList.Add(column);
            }
            schemaList.Add("Quantity");
            schemaList.Add("InputQty");

            return((string[])schemaList.ToArray(typeof(string)));
        }
        private string[] getOWCSchema2()
        {
            string[] rows    = TimingType.ParserAttributeTimingType(this.rblTimingType.SelectedValue);
            string[] columns = SummaryTarget.ParserAttributeSummaryTarget2(this.rblSummaryTarget.SelectedValue);
            string[] fields  = YieldCatalog.ParserTotalFields(this.V_SummaryTarget, this.rblYieldCatalog.SelectedValue);

            ArrayList schemaList = new ArrayList();

            foreach (string row in rows)
            {
                schemaList.Add(row);
            }
            foreach (string column in columns)
            {
                schemaList.Add(column);
            }
            foreach (string field in fields)
            {
                schemaList.Add(field);
            }

            return((string[])schemaList.ToArray(typeof(string)));
        }
        public static void SendTiming(string Category, string Variable, string Label, TimingType timingType, int Milliseconds)
        {
            string Payload = HitTypeToString(HitType.Timing) +
                             "&utc=" + Category + // User timing category
                             "&utv=" + Variable + // User timing variable name
                             "&utl=" + Label;     // User timing label

            switch (timingType)
            {
            case TimingType.UserTimingTime:
                Payload += "&utt=" + Milliseconds.ToString();     // User timing time
                break;

            case TimingType.PageLoadTime:
                Payload += "&plt=" + Milliseconds.ToString();     // Page Load Time
                break;

            case TimingType.DNSTime:
                Payload += "&dns=" + Milliseconds.ToString();     // DNS Time
                break;

            case TimingType.PageDownloadTime:
                Payload += "&pdt=" + Milliseconds.ToString();     // Page Download Time
                break;

            case TimingType.RedirectResponseTime:
                Payload += "&rrt=" + Milliseconds.ToString();     // Redirect Response Time
                break;

            case TimingType.TCPConnectTime:
                Payload += "&tcp=" + Milliseconds.ToString();     // TCP Connect Time
                break;

            case TimingType.ServerResponseTime:
                Payload += "&srt=" + Milliseconds.ToString();     // Server Response Time
                break;

            case TimingType.DOMInteractiveTime:
                Payload += "&dit=" + Milliseconds.ToString();     // DOM Interactive Time
                break;

            case TimingType.ContentLoadTime:
                Payload += "&clt=" + Milliseconds.ToString();     // Content Load Time
                break;
            }
            SendPayload(Payload);
        }
        private void _doQuery()
        {
            if (this._checkRequireFields())
            {
                object[] dateSource = this._loadDataSource();

                if (dateSource == null || dateSource.Length <= 0)
                {
                    this.gridWebGrid.Visible   = false;
                    this.cmdGridExport.Visible = false;
                    this.lineChart.Visible     = false;
                    this.columnChart.Visible   = false;

                    return;
                }
                NewReportDomainObject[] dateSourceForOWC = this.ToNewReportDomainObject(dateSource);
                //数据加载到Grid
                List <string> fixedColumnList = new List <string>();
                string[]      fixedColumn     = TimingType.ParserAttributeTimingType4(this.rblTimingType.SelectedValue);
                if (fixedColumn != null)
                {
                    foreach (string row in fixedColumn)
                    {
                        fixedColumnList.Add(row);
                    }
                }

                List <string> dim2PropertyList = new List <string>();
                string        dim2Columns      = SummaryTarget.ParserAttributeSummaryTarget3(this.rblSummaryTarget.SelectedValue);
                if (dim2Columns != null)
                {
                    dim2PropertyList.Add(dim2Columns);
                }


                List <ReportGridDim3Property> dim3PropertyList = new List <ReportGridDim3Property>();


                if (this.rblYieldCatalog.SelectedValue.ToUpper() == "yieldcatalog_ppm".ToUpper())
                {
                    dim3PropertyList.Add(new ReportGridDim3Property("TotalLocation", "0", "SUM", "SUM", false));
                    dim3PropertyList.Add(new ReportGridDim3Property("NotYieldLocation", "0", "SUM", "SUM", false));
                    dim3PropertyList.Add(new ReportGridDim3Property("PPM", "0.00%", "DIV({-1},{-2})", "DIV({-1},{-2})", false));
                }
                else if (this.rblYieldCatalog.SelectedValue.ToUpper() == "yieldcatalog_allgood".ToUpper())
                {
                    dim3PropertyList.Add(new ReportGridDim3Property("Quantity", "0", "SUM", "SUM", false));
                    dim3PropertyList.Add(new ReportGridDim3Property("AllGoodQuantity", "0", "SUM", "SUM", false));
                    dim3PropertyList.Add(new ReportGridDim3Property("AllGoodYieldPercent", "0.00%", "DIV({-1},{-2})", "DIV({-1},{-2})", false));
                }
                else if (this.rblYieldCatalog.SelectedValue.ToUpper() == "yieldcatalog_notyield".ToUpper())
                {
                    if (string.Compare(this.V_SummaryTarget, SummaryTarget.Operation, true) == 0 ||
                        string.Compare(this.V_SummaryTarget, SummaryTarget.Resource, true) == 0)
                    {
                        dim3PropertyList.Add(new ReportGridDim3Property("AllTimes", "0", "SUM", "SUM", false));
                        dim3PropertyList.Add(new ReportGridDim3Property("NGTimes", "0", "SUM", "SUM", false));
                        dim3PropertyList.Add(new ReportGridDim3Property("NotYieldPercent", "0.00%", "DIV({-1},{-2})", "DIV({-1},{-2})", false));
                    }
                    else
                    {
                        dim3PropertyList.Add(new ReportGridDim3Property("InputQty", "0", "SUM", "SUM", false));
                        dim3PropertyList.Add(new ReportGridDim3Property("NGTimes", "0", "SUM", "SUM", false));
                        dim3PropertyList.Add(new ReportGridDim3Property("NotYieldPercent", "0.00%", "DIV({-1},{-2})", "DIV({-1},{-2})", false));
                    }
                }

                //visible style : pivot or chart
                if (this.rblVisibleStyle.SelectedValue.ToUpper() == VisibleStyle.Pivot.ToUpper())
                {
                    ReportGridHelperNew reportGridHelper = new ReportGridHelperNew(this.DataProvider, this.languageComponent1, this.gridWebGrid, this.DtSource);

                    reportGridHelper.DataSource                   = dateSourceForOWC;
                    reportGridHelper.Dim1PropertyList             = fixedColumnList;
                    reportGridHelper.Dim2PropertyList             = dim2PropertyList;
                    reportGridHelper.Dim3PropertyList             = dim3PropertyList;
                    reportGridHelper.HasDim3PropertyNameRowColumn = true;
                    reportGridHelper.ShowGrid();

                    this.gridWebGrid.Visible   = true;
                    this.cmdGridExport.Visible = true;
                    this.lineChart.Visible     = false;
                    this.columnChart.Visible   = false;
                }
                if (this.rblVisibleStyle.SelectedValue.ToUpper() == VisibleStyle.Chart.ToUpper())
                {
                    string[] fields       = YieldCatalog.ParserTotalFields(this.V_SummaryTarget, this.rblYieldCatalog.SelectedValue);
                    string   propertyName = this.languageComponent1.GetString(dim3PropertyList[0].Name);

                    List <string> rowPropertyList = new List <string>();
                    string[]      listRows        = TimingType.ParserAttributeTimingType4(this.rblTimingType.SelectedValue);
                    if (listRows != null)
                    {
                        foreach (string row in listRows)
                        {
                            rowPropertyList.Add(row);
                        }
                    }

                    List <string> valuePropertyList = new List <string>();
                    foreach (ReportGridDim3Property property in dim3PropertyList)
                    {
                        if (!property.Hidden)
                        {
                            valuePropertyList.Add(property.Name);
                        }
                    }
                    List <string> dataPropertyList = valuePropertyList;

                    foreach (NewReportDomainObject obj in dateSourceForOWC)
                    {
                        if (fields != null)
                        {
                            foreach (string field in fields)
                            {
                                if (field.ToUpper() == "NotYieldPercent".ToUpper())
                                {
                                    obj.TempValue = obj.NotYieldPercent.ToString();
                                }
                                else if (field.ToUpper() == "PPM".ToUpper())
                                {
                                    obj.TempValue = obj.PPM.ToString();
                                }
                                else if (field.ToUpper() == "AllGoodYieldPercent".ToUpper())
                                {
                                    obj.TempValue = obj.AllGoodYieldPercent.ToString();
                                }
                            }
                        }

                        //时段、班次、天、周、月、年
                        if (this.rblTimingType.SelectedValue == TimingType.TimePeriod.ToString())
                        {
                            obj.PeriodCode = obj.PeriodCode.ToString();
                        }

                        if (this.rblTimingType.SelectedValue == TimingType.Shift.ToString())
                        {
                            obj.PeriodCode = obj.ShiftCode.ToString();
                        }

                        if (this.rblTimingType.SelectedValue == TimingType.Day.ToString())
                        {
                            obj.PeriodCode = obj.ShiftDay.ToString();
                        }

                        if (this.rblTimingType.SelectedValue == TimingType.Week.ToString())
                        {
                            obj.PeriodCode = obj.Week.ToString();
                        }

                        if (this.rblTimingType.SelectedValue == TimingType.Month.ToString())
                        {
                            obj.PeriodCode = obj.Month.ToString();
                        }
                        //end
                    }

                    //chart display : histogram or line
                    if (this.rblChartType.SelectedValue.ToUpper() == ChartStyle.Histogram.ToUpper())
                    {
                        this.columnChart.Visible = true;
                        this.lineChart.Visible   = false;

                        columnChart.ChartGroupByString = dim2Columns;
                        //设置首页报表的大小
                        if (ViewState["Width"] != null)
                        {
                            columnChart.Width = int.Parse(ViewState["Width"].ToString());
                        }

                        if (ViewState["Height"] != null)
                        {
                            columnChart.Height = int.Parse(ViewState["Height"].ToString());
                        }
                        //end
                        this.columnChart.ChartTextFormatString = "<DATA_VALUE:#0.##%>";
                        this.columnChart.YLabelFormatString    = "<DATA_VALUE:#0.##%>";
                        this.columnChart.DataType   = true;
                        this.columnChart.DataSource = dateSourceForOWC;
                        this.columnChart.DataBind();
                    }
                    if (this.rblChartType.SelectedValue.ToUpper() == ChartStyle.Line.ToUpper())
                    {
                        this.columnChart.Visible = false;
                        this.lineChart.Visible   = true;

                        lineChart.ChartGroupByString = dim2Columns;

                        //设置首页报表的大小
                        if (ViewState["Width"] != null)
                        {
                            lineChart.Width = int.Parse(ViewState["Width"].ToString());
                        }

                        if (ViewState["Height"] != null)
                        {
                            lineChart.Height = int.Parse(ViewState["Height"].ToString());
                        }
                        //end

                        this.lineChart.ChartTextFormatString = "<DATA_VALUE:#0.##%>";
                        this.lineChart.YLabelFormatString    = "<DATA_VALUE:#0.##%>";
                        this.lineChart.DataType   = true;
                        this.lineChart.DataSource = dateSourceForOWC;
                        this.lineChart.DataBind();
                    }
                    this.gridWebGrid.Visible   = false;
                    this.cmdGridExport.Visible = false;
                    Response.Write("<script type='text/javascript'>scrollToBottom=true;</script>");
                }
            }
        }
Exemplo n.º 15
0
    private InstrumentClip GetInstrumentClip()
    {
        int beat = (int)Mathf.Round(GlobalBeat.ProgressInMeasure());
        float dist = GlobalBeat.SecondsFromBeat();

        //Debug.Log("Range: " + dist);

        // Clips in range
        // Filter out the farther ones?
        List<InstrumentClip> clips = Sounds.Where(c => dist < c.range).ToList();

        if (AClipForEveryBeat)
            clips = clips.Where(c => c.BeatTarget == beat).ToList();

        // Check for criticals (else just return the same list)
        clips = ReturnCritsIfCritical(clips);

        // Play a different clip than the last one if its possible
        List<InstrumentClip> alternatives = clips.Where(c => c.SampleName != LastSampleName).ToList();//.Where(c => c != lastInstrumentClip).ToList();
        if (alternatives.Count > 0)
            clips = alternatives;

        //Debug.Log("alternatives: " + alternatives.Count + " " + LastSampleName + " " + dist + " ");
        //DebugList<string>(alternatives.Select(c => c.SampleName).ToList());

        // Find a random clip from the list
        InstrumentClip clip = clips[Random.Range(0, clips.Count)];

        if (clip.IsCritical)
            timingType = TimingType.Critical;
        else
            timingType = TimingType.Normal;
        //No low yet

        return clip;
    }
        private void _doQuery()
        {
            if (this._checkRequireFields())
            {
                this.OWCPivotTable1.ClearFieldSet();

                object[] dateSource = this._loadDataSource();

                //统一使用透视表处理数据
                this.OWCPivotTable1.SetDataSource(
                    dateSource,
                    this.getOWCSchema2());


                //visible style : pivot or chart
                if (this.rblVisibleStyle.SelectedValue.ToUpper() == VisibleStyle.Pivot.ToUpper())
                {
                    string[] rows = TimingType.ParserAttributeTimingType(this.rblTimingType.SelectedValue);
                    if (rows != null)
                    {
                        foreach (string row in rows)
                        {
                            this.OWCPivotTable1.AddRowFieldSet(row, false);
                        }
                    }
                    //categories
                    string[] columns = SummaryTarget.ParserAttributeSummaryTarget2(this.rblSummaryTarget.SelectedValue);
                    if (columns != null)
                    {
                        foreach (string column in columns)
                        {
                            this.OWCPivotTable1.AddColumnFieldSet(column, false);
                        }
                    }
                    //values
                    //投入数
                    this.OWCPivotTable1.AddTotalField(
                        this.languageComponent1.GetString("InputQty"),
                        "InputQty",
                        PivotTotalFunctionType.Sum);

                    //产出数(产量)
                    this.OWCPivotTable1.AddTotalField(
                        this.languageComponent1.GetString("Quantity1"),
                        "Quantity",
                        PivotTotalFunctionType.Sum);
                    this.OWCChartSpace1.Display = false;
                    this.OWCPivotTable1.Display = true;
                }
                if (this.rblVisibleStyle.SelectedValue.ToUpper() == VisibleStyle.Chart.ToUpper())
                {
                    string[] rows = TimingType.ParserAttributeTimingType2(this.rblTimingType.SelectedValue);
                    if (rows != null)
                    {
                        foreach (string row in rows)
                        {
                            this.OWCPivotTable1.AddRowFieldSet(row, true);
                        }
                    }

                    //categories
//					string[] columns = SummaryTarget.ParserAttributeSummaryTarget2( this.rblSummaryTarget.SelectedValue );
//					if( columns != null )
//					{
//						foreach(string column in columns)
//						{
//							this.OWCPivotTable1.AddColumnFieldSet(column,false);
//						}
//					}
                    this.OWCPivotTable1.AddColumnFieldSet(
                        SummaryTarget.ParserAttributeSummaryTarget(this.rblSummaryTarget.SelectedValue),
                        true);

                    //values
                    //投入数
                    this.OWCPivotTable1.AddTotalField(
                        this.languageComponent1.GetString("InputQty"),
                        "InputQty",
                        PivotTotalFunctionType.Sum);

                    //产出数(产量)
                    this.OWCPivotTable1.AddTotalField(
                        this.languageComponent1.GetString("Quantity1"),
                        "Quantity",
                        PivotTotalFunctionType.Sum);
                    this.OWCChartSpace1.Display    = false;
                    this.OWCPivotTable1.Display    = true;
                    this.OWCChartSpace1.DataSource = this.OWCPivotTable1.PivotTableName;

                    //chart display : histogram or line
                    if (this.rblChartType.SelectedValue.ToUpper() == ChartStyle.Histogram.ToUpper())
                    {
                        this.OWCChartSpace1.ChartType = OWCChartType.ColumnClustered;
                    }
                    if (this.rblChartType.SelectedValue.ToUpper() == ChartStyle.Line.ToUpper())
                    {
                        //this.OWCChartSpace1.ChartType = OWCChartType.Line;
                        this.OWCChartSpace1.ChartType = OWCChartType.LineMarkers;
                    }

                    this.OWCPivotTable1.Display = false;
                    this.OWCChartSpace1.Display = true;
                }
            }
        }
Exemplo n.º 17
0
 public Timing(TimingType type, bool isBefore) : this(type) { IsBefore = isBefore; }
Exemplo n.º 18
0
 public Timing(TimingType type)
 {
     Type = type;
 }
Exemplo n.º 19
0
        /// <summary>
        /// Initializes the book.
        /// </summary>
        /// <returns></returns>
        public TimingType Initialize()
        {
            this.Book = EPubParser.Parse(this.file);

            // Change tooltip and header.
            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
            {
                this.Header  = this.Book.Title.Truncate(30);
                this.ToolTip = this.Book.Title;
            }));

            using (MD5 md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(this.file))
                {
                    this.Book.Checksum = BitConverter.ToString(md5.ComputeHash(stream));
                }
            }

            // Craete the tmp image folder if it doesn't exist.
            if (!Directory.Exists(this.TabFolder + "/images"))
            {
                Directory.CreateDirectory(this.TabFolder + "/images");
            }

            // Save all the images from the ebook to the image folder.
            for (int i = 0; i < Book.Images.Count; i++)
            {
                using (FileStream file = new FileStream(this.TabFolder + "/images/" + Book.Images[i].FileName, FileMode.Create, System.IO.FileAccess.Write))
                {
                    byte[] bytes = new byte[Book.Images[i].Content.Length];
                    Book.Images[i].Content.Read(bytes, 0, (int)Book.Images[i].Content.Length);
                    file.Write(bytes, 0, bytes.Length);
                    Book.Images[i].Content.Close();
                }
            }

            // Save the html file.
            File.WriteAllText(this.TabFolder + "/index.html", Book.Content);

            // Navigate to the newly created html file.
            string curDir = Directory.GetCurrentDirectory();

            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
            {
                this.Browser.Navigate(new Uri(string.Format("file:///{0}/{1}/index.html", curDir, this.TabFolder)));
            }));

            timingType = this.speechTimer.LoadExisting(this.Book);

            if (timingType != TimingType.NORMAL)
            {
                for (int i = 0; i < this.Book.AudioFiles.Count; i++)
                {
                    this.Book.AudioFiles[i].Dispose();
                }
                this.Book.AudioFiles.Clear();

                if (timingType == TimingType.MISSING_AUDIO)
                {
                    string timingsFile = MainWindow.TimingsFolder + @"\" + this.Book.Checksum + ".xml";
                    if (File.Exists(timingsFile))
                    {
                        MessageBox.Show("You must select the correct audiofiles.", "Notification", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                else
                {
                    #region TimingType is either Corrupt or progress

                    string progressFile = MainWindow.TimingsFolder + @"\" + this.Book.Checksum + ".progress";
                    if (File.Exists(progressFile))
                    {
                        if (MessageBox.Show("A manual timing progress file exists.\nShould this file be deleted?", "File found", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            File.Delete(progressFile);
                        }
                        else
                        {
                            try
                            {
                                XmlDocument xmlDoc = new XmlDocument();
                                xmlDoc.Load(progressFile);

                                this.Book.Successrate = Convert.ToSingle(((XmlElement)xmlDoc.GetElementsByTagName("Book")[0]).GetAttribute("Successrate"));

                                XmlNodeList audioFilesList = xmlDoc.GetElementsByTagName("AudioFile");
                                foreach (XmlElement audioFileElement in audioFilesList)
                                {
                                    if (File.Exists(audioFileElement.GetAttribute("Path")))
                                    {
                                        this.Book.AudioFiles.Add(new AudioFile(audioFileElement.GetAttribute("Path")));
                                    }
                                }

                                if (this.Book.AudioFiles.Count == 0)
                                {
                                    MessageBox.Show("You must select the correct audiofiles.", "Notification", MessageBoxButton.OK, MessageBoxImage.Information);
                                    timingType = TimingType.MISSING_AUDIO;
                                }

                                XmlElement  chaptersElement = (XmlElement)xmlDoc.GetElementsByTagName("Chapters").Item(0);
                                XmlNodeList chapterNodeList = chaptersElement.GetElementsByTagName("Chapter");
                                foreach (XmlElement chapterElement in chapterNodeList)
                                {
                                    this.CurrentChapterIndex++;
                                    this.ManualTimings.Add(CurrentChapterIndex, new List <AudioPosition>());

                                    XmlNodeList sentenceNodeList = chapterElement.GetElementsByTagName("Sentence");
                                    foreach (XmlElement sentenceElement in chapterElement)
                                    {
                                        CurrentSentenceIndex++;
                                        this.ManualTimings[CurrentChapterIndex].Add(new AudioPosition()
                                        {
                                            AudioFileIndex = Convert.ToInt32(sentenceElement.GetAttribute("AudioFileIndex")),
                                            Position       = TimeSpan.Parse(sentenceElement.GetAttribute("AudioPosition")),
                                            Duration       = TimeSpan.Parse(sentenceElement.GetAttribute("Duration"))
                                        });
                                    }

                                    this.CurrentSentenceIndex = 0;
                                }

                                if (timingType != TimingType.MISSING_AUDIO)
                                {
                                    timingType = TimingType.PROGRESS;

                                    TimeSpan savedAudioPosition  = TimeSpan.Zero;
                                    int      savedAudioFileIndex = 0;
                                    float    savedVolume         = 0;

                                    // Read the current audio file and position from the XML document.
                                    lock (xmlLock)
                                    {
                                        if (File.Exists(progressFile))
                                        {
                                            XmlDocument doc = new XmlDocument();
                                            doc.Load(progressFile);

                                            savedVolume         = Convert.ToSingle(((XmlElement)doc.GetElementsByTagName("Book").Item(0)).GetAttribute("Volume"));
                                            savedAudioFileIndex = Convert.ToInt32(((XmlElement)doc.GetElementsByTagName("Book").Item(0)).GetAttribute("CurrentAudioFileIndex"));
                                            savedAudioPosition  = TimeSpan.Parse(((XmlElement)doc.GetElementsByTagName("Book").Item(0)).GetAttribute("CurrentAudioPosition"));
                                        }
                                    }

                                    this.SelectAudioFile(savedAudioFileIndex);
                                    this.CurrentAudioFile.CurrentTime = savedAudioPosition;
                                    this.Volume = savedVolume;

                                    this.IsAudioLoading = false;
                                    this.LoadingText    = string.Empty;
                                    if (this.LoadingCompleted != null)
                                    {
                                        this.LoadingCompleted(this, EventArgs.Empty);
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("The progress file is corrupt, it will be removed,\ncopy it if you want to save it before you click OK.", "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
                                File.Delete(progressFile);
                            }
                        }
                    }

                    #endregion
                }
            }
            else
            {
                #region TimingType is set to normal

                string xmlFile = MainWindow.TimingsFolder + @"\" + this.Book.Checksum + ".xml";

                TimeSpan savedAudioPosition  = TimeSpan.Zero;
                int      savedAudioFileIndex = 0;
                float    savedVolume         = 0;

                // Read the current audio file and position from the XML document.
                lock (xmlLock)
                {
                    if (File.Exists(xmlFile))
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.Load(xmlFile);

                        savedVolume         = Convert.ToSingle(((XmlElement)doc.GetElementsByTagName("Book").Item(0)).GetAttribute("Volume"));
                        savedAudioFileIndex = Convert.ToInt32(((XmlElement)doc.GetElementsByTagName("Book").Item(0)).GetAttribute("CurrentAudioFileIndex"));
                        savedAudioPosition  = TimeSpan.Parse(((XmlElement)doc.GetElementsByTagName("Book").Item(0)).GetAttribute("CurrentAudioPosition"));
                    }
                }

                this.SelectAudioFile(savedAudioFileIndex);
                this.CurrentAudioFile.CurrentTime = savedAudioPosition;
                this.Volume = savedVolume;

                this.IsLoaded = true;

                this.LoadingText = string.Empty;
                if (this.LoadingCompleted != null)
                {
                    this.LoadingCompleted(this, EventArgs.Empty);
                }

                #endregion
            }

            return(timingType);
        }
        private void _DoQuery()
        {
            DtSource = new DataTable();
            this.gridWebGrid.ClearDataSource();
            this.gridWebGrid.Columns.Clear();
            this.gridHelper = new GridHelperNew(this.gridWebGrid, this.DtSource);

            if (this._checkRequireFields())
            {
                this.AutoRefresh = this.chbRefreshAuto.Checked;

                string byTimeType = TimingType.ParserAttributeTimingType3(this.rblTimingType.SelectedValue);


                //一般数据
                object[] dateSource = this._loadDataSource();

                if (dateSource == null || dateSource.Length <= 0)
                {
                    this.gridWebGrid.Visible   = false;
                    this.cmdGridExport.Visible = false;
                    this.lineChart.Visible     = false;
                    this.columnChart.Visible   = false;

                    ReportPageHelper.SetPageScrollToBottom(this);
                    return;
                }

                NewReportDomainObject[] dateSourceForOWC = this.ToNewReportDomainObject(dateSource);
                object[] dateSourceCompare = new NewReportDomainObject[0] {
                };

                //数据加载到Grid
                List <string> fixedColumnList = new List <string>();
                string        ColumnList      = SummaryTarget.ParserAttributeSummaryTarget3(this.rblSummaryTarget.SelectedValue);
                fixedColumnList.Add(ColumnList);
                this.txtColumn.Text = ColumnList;

                List <ReportGridDim3Property> dim3PropertyList = new List <ReportGridDim3Property>();

                dim3PropertyList.Add(new ReportGridDim3Property("InputQty", "0", "SUM", "SUM", false));
                dim3PropertyList.Add(new ReportGridDim3Property("OutputQty", "0", "SUM", "SUM", false));


                ReportGridHelperNew reportGridHelper = new ReportGridHelperNew(this.DataProvider, this.languageComponent1, this.gridWebGrid, DtSource);

                reportGridHelper.DataSource                   = dateSourceForOWC;
                reportGridHelper.DataSourceForCompare         = dateSourceCompare;
                reportGridHelper.Dim1PropertyList             = fixedColumnList;
                reportGridHelper.Dim3PropertyList             = dim3PropertyList;
                reportGridHelper.HasDim3PropertyNameRowColumn = true;
                reportGridHelper.CompareType                  = "";
                reportGridHelper.ByTimeType                   = byTimeType;

                reportGridHelper.ShowGrid();
                base.InitWebGrid();


                //获取表格和图示
                if (UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.Grid)
                {
                    this.gridWebGrid.Visible   = true;
                    this.cmdGridExport.Visible = true;
                    this.lineChart.Visible     = false;
                    this.columnChart.Visible   = false;
                }
                else if (UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.LineChart ||
                         UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.PieChart ||
                         UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.HistogramChart)
                {
                    string propertyName = this.languageComponent1.GetString(dim3PropertyList[0].Name);
                    foreach (NewReportDomainObject domainObject in dateSourceForOWC)
                    {
                        domainObject.EAttribute1 = propertyName + domainObject.EAttribute1;
                    }

                    List <string> rowPropertyList = new List <string>();
                    string[]      rows            = TimingType.ParserAttributeTimingType2(this.rblTimingType.SelectedValue);
                    if (rows != null)
                    {
                        foreach (string row in rows)
                        {
                            rowPropertyList.Add(row);
                        }
                    }

                    List <string> columnPropertyList = new List <string>();
                    string[]      columns            = SummaryTarget.ParserAttributeSummaryTarget2(this.rblSummaryTarget.SelectedValue);
                    if (columns != null)
                    {
                        foreach (string column in columns)
                        {
                            columnPropertyList.Add(column);
                        }
                    }
                    columnPropertyList.Add("EAttribute1");
                    List <string> valuePropertyList = new List <string>();
                    foreach (ReportGridDim3Property property in dim3PropertyList)
                    {
                        if (!property.Hidden)
                        {
                            valuePropertyList.Add(property.Name);
                        }
                    }
                    List <string> dataPropertyList = valuePropertyList;

                    foreach (NewReportDomainObject obj in dateSourceForOWC)
                    {
                        obj.TempValue = obj.InputQty.ToString();

                        //时段、班次、天、周、月、年
                        if (this.rblTimingType.SelectedValue == TimingType.TimePeriod.ToString())
                        {
                            obj.PeriodCode = obj.PeriodCode.ToString();
                        }

                        if (this.rblTimingType.SelectedValue == TimingType.Shift.ToString())
                        {
                            obj.PeriodCode = obj.ShiftCode.ToString();
                        }

                        if (this.rblTimingType.SelectedValue == TimingType.Day.ToString())
                        {
                            obj.PeriodCode = obj.ShiftDay.ToString();
                        }

                        if (this.rblTimingType.SelectedValue == TimingType.Week.ToString())
                        {
                            obj.PeriodCode = obj.Week.ToString();
                        }

                        if (this.rblTimingType.SelectedValue == TimingType.Month.ToString())
                        {
                            obj.PeriodCode = obj.Month.ToString();
                        }
                        //end
                    }

                    if (UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.LineChart)
                    {
                        this.columnChart.Visible = false;
                        this.lineChart.Visible   = true;

                        lineChart.ChartGroupByString = ColumnList;

                        //设置首页报表的大小
                        if (ViewState["Width"] != null)
                        {
                            lineChart.Width = int.Parse(ViewState["Width"].ToString());
                        }

                        if (ViewState["Height"] != null)
                        {
                            lineChart.Height = int.Parse(ViewState["Height"].ToString());
                        }
                        //end

                        this.lineChart.ChartTextFormatString = "<DATA_VALUE:0.##>";
                        this.lineChart.YLabelFormatString    = "<DATA_VALUE:0.##>";
                        this.lineChart.DataType   = true;
                        this.lineChart.DataSource = dateSourceForOWC;
                        this.lineChart.DataBind();
                    }
                    else if (UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.HistogramChart)
                    {
                        this.columnChart.Visible = true;
                        this.lineChart.Visible   = false;

                        columnChart.ChartGroupByString = ColumnList;
                        //设置首页报表的大小
                        if (ViewState["Width"] != null)
                        {
                            columnChart.Width = int.Parse(ViewState["Width"].ToString());
                        }

                        if (ViewState["Height"] != null)
                        {
                            columnChart.Height = int.Parse(ViewState["Height"].ToString());
                        }
                        //end
                        this.columnChart.ChartTextFormatString = "<DATA_VALUE:0.##>";
                        this.columnChart.YLabelFormatString    = "<DATA_VALUE:0.##>";
                        this.columnChart.DataType   = true;
                        this.columnChart.DataSource = dateSourceForOWC;
                        this.columnChart.DataBind();
                    }
                    else
                    {
                        this.columnChart.Visible = false;
                        this.lineChart.Visible   = false;
                    }

                    this.gridWebGrid.Visible = false;

                    this.cmdGridExport.Visible = false;
                }

                ReportPageHelper.SetPageScrollToBottom(this);
            }
            else
            {
                this.chbRefreshAuto.Checked = false;
                this.AutoRefresh            = false;
            }
            this.gridWebGrid.Behaviors.RowSelectors.RowNumbering = false;
            this.gridWebGrid.Behaviors.Sorting.Enabled           = false;
        }
Exemplo n.º 21
0
        private void _doQuery()
        {
            if (this._checkRequireFields())
            {
                this.OWCPivotTable1.ClearFieldSet();

                object[] dateSource = this._loadDataSource();

                //统一使用透视表处理数据
                this.OWCPivotTable1.SetDataSource(
                    dateSource, this.getOWCSchema2());

                //visible style : pivot or chart
                if (this.rblVisibleStyle.SelectedValue.ToUpper() == VisibleStyle.Pivot.ToUpper())
                {
                    //categories
                    string[] rows = TimingType.ParserAttributeTimingType(this.rblTimingType.SelectedValue);
                    if (rows != null)
                    {
                        foreach (string row in rows)
                        {
                            this.OWCPivotTable1.AddRowFieldSet(row, false);
                        }
                    }

//					this.OWCPivotTable1.AddColumnFieldSet(
//						SummaryTarget.ParserAttributeSummaryTarget( this.V_SummaryTarget ),
//						true);
                    string[] columns = SummaryTarget.ParserAttributeSummaryTarget2(this.rblSummaryTarget.SelectedValue, this.rblYieldCatalog.SelectedValue);
                    if (columns != null)
                    {
                        foreach (string column in columns)
                        {
                            this.OWCPivotTable1.AddColumnFieldSet(column, false);
                        }
                    }

                    //values
                    string[] fields = YieldCatalog.ParserTotalFields(this.V_SummaryTarget, this.rblYieldCatalog.SelectedValue);
                    if (fields != null)
                    {
                        foreach (string field in fields)
                        {
                            if (field.ToUpper() == "YieldPercent".ToUpper())
                            {
                                this.OWCPivotTable1.AddTotalField(
                                    this.languageComponent1.GetString(field),
                                    field,
                                    PivotTotalFunctionType.Average, NumberFormat.Percent);
                            }
                            else if (field.ToUpper() == "PPM".ToUpper())
                            {
                                this.OWCPivotTable1.AddCalculatedTotalField(
                                    "PPM",
                                    "PPM",
                                    "round( [" + this.languageComponent1.GetString("NotYieldNum") + "]/[" + this.languageComponent1.GetString("TotalLocation") + "]*1000000 , 0 )",
                                    PivotTotalFunctionType.Calculated);
                            }
                            else if (field.ToUpper() == "AllGoodYieldPercent".ToUpper())
                            {
                                this.OWCPivotTable1.AddCalculatedTotalField(
                                    this.languageComponent1.GetString(field),
                                    this.languageComponent1.GetString(field),
                                    "[" + this.languageComponent1.GetString("AllGoodQuantity") + "]/[" + this.languageComponent1.GetString("Quantity") + "]",
                                    PivotTotalFunctionType.Calculated,
                                    NumberFormat.Percent);
                            }
                            else if (field.ToUpper() == "NotYieldPercent".ToUpper())
                            {
                                if (string.Compare(this.V_SummaryTarget, SummaryTarget.Operation, true) == 0 ||
                                    string.Compare(this.V_SummaryTarget, SummaryTarget.Resource, true) == 0)
                                {
                                    this.OWCPivotTable1.AddCalculatedTotalField(
                                        this.languageComponent1.GetString(field),
                                        this.languageComponent1.GetString(field),
                                        "[" + this.languageComponent1.GetString("NGTimes") + "]/[" + this.languageComponent1.GetString("AllTimes") + "]",
                                        PivotTotalFunctionType.Calculated,
                                        NumberFormat.Percent);
                                }
                                else
                                {
                                    this.OWCPivotTable1.AddCalculatedTotalField(
                                        this.languageComponent1.GetString(field),
                                        this.languageComponent1.GetString(field),
                                        "[" + this.languageComponent1.GetString("NGTimes") + "]/[" + this.languageComponent1.GetString("InputQty") + "]",
                                        PivotTotalFunctionType.Calculated,
                                        NumberFormat.Percent);
                                }
                            }
                            else
                            {
                                this.OWCPivotTable1.AddTotalField(
                                    this.languageComponent1.GetString(field),
                                    field,
                                    PivotTotalFunctionType.Sum);
                            }
                        }
                    }

                    this.OWCPivotTable1.Display = true;
                    this.OWCChartSpace1.Display = false;
                }
                if (this.rblVisibleStyle.SelectedValue.ToUpper() == VisibleStyle.Chart.ToUpper())
                {
                    //categories
                    string[] rows = TimingType.ParserAttributeTimingType2(this.rblTimingType.SelectedValue);
                    if (rows != null)
                    {
                        foreach (string row in rows)
                        {
                            this.OWCPivotTable1.AddRowFieldSet(row, true);
                        }
                    }

                    this.OWCPivotTable1.AddColumnFieldSet(
                        SummaryTarget.ParserAttributeSummaryTarget(this.V_SummaryTarget),
                        true);

                    //values
                    this.OWCPivotTable1.RemoveAllTotalField();

                    string[] fields = YieldCatalog.ParserTotalFields(this.V_SummaryTarget, this.rblYieldCatalog.SelectedValue);
                    if (fields != null)
                    {
                        foreach (string field in fields)
                        {
                            if (field.ToUpper() == "YieldPercent".ToUpper())
                            {
                                this.OWCPivotTable1.AddTotalField(
                                    this.languageComponent1.GetString(field),
                                    field,
                                    PivotTotalFunctionType.Average, NumberFormat.Percent);
                            }
                            else if (field.ToUpper() == "PPM".ToUpper())
                            {
                                this.OWCPivotTable1.AddCalculatedTotalField(
                                    "PPM",
                                    "PPM",
                                    "round( [" + this.languageComponent1.GetString("NotYieldNum") + "]/[" + this.languageComponent1.GetString("TotalLocation") + "]*1000000 , 0 )",
                                    PivotTotalFunctionType.Calculated);
                            }
                            else if (field.ToUpper() == "AllGoodYieldPercent".ToUpper())
                            {
                                this.OWCPivotTable1.AddCalculatedTotalField(
                                    this.languageComponent1.GetString(field),
                                    this.languageComponent1.GetString(field),
                                    "[" + this.languageComponent1.GetString("AllGoodQuantity") + "]/[" + this.languageComponent1.GetString("Quantity") + "]",
                                    PivotTotalFunctionType.Calculated,
                                    NumberFormat.Percent);
                            }
                            else if (field.ToUpper() == "NotYieldPercent".ToUpper())
                            {
                                if (string.Compare(this.V_SummaryTarget, SummaryTarget.Operation, true) == 0 ||
                                    string.Compare(this.V_SummaryTarget, SummaryTarget.Resource, true) == 0)
                                {
                                    this.OWCPivotTable1.AddCalculatedTotalField(
                                        this.languageComponent1.GetString(field),
                                        this.languageComponent1.GetString(field),
                                        "[" + this.languageComponent1.GetString("NGTimes") + "]/[" + this.languageComponent1.GetString("AllTimes") + "]",
                                        PivotTotalFunctionType.Calculated,
                                        NumberFormat.Percent);
                                }
                                else
                                {
                                    this.OWCPivotTable1.AddCalculatedTotalField(
                                        this.languageComponent1.GetString(field),
                                        this.languageComponent1.GetString(field),
                                        "[" + this.languageComponent1.GetString("NGTimes") + "]/[" + this.languageComponent1.GetString("InputQty") + "]",
                                        PivotTotalFunctionType.Calculated,
                                        NumberFormat.Percent);
                                }
                            }
                            else
                            {
                                /*	Removed by Icyer 2007/01/17		在后面添加
                                 * this.OWCPivotTable1.AddTotalField(
                                 *      this.languageComponent1.GetString(field),
                                 *      field,
                                 *      PivotTotalFunctionType.Sum);
                                 */
                            }
                        }
                        // Added by Icyer 2007/01/17	将统计栏位提后
                        foreach (string field in fields)
                        {
                            if (field.ToUpper() == "YieldPercent".ToUpper() ||
                                field.ToUpper() == "PPM".ToUpper() ||
                                field.ToUpper() == "AllGoodYieldPercent".ToUpper() ||
                                field.ToUpper() == "NotYieldPercent".ToUpper())
                            {
                            }
                            else
                            {
                                this.OWCPivotTable1.AddTotalField(
                                    this.languageComponent1.GetString(field),
                                    field,
                                    PivotTotalFunctionType.Sum);
                            }
                        }
                        // Added end
                    }

                    this.OWCChartSpace1.DataSource = this.OWCPivotTable1.PivotTableName;

                    //chart display : histogram or line
                    if (this.rblChartType.SelectedValue.ToUpper() == ChartStyle.Histogram.ToUpper())
                    {
                        this.OWCChartSpace1.ChartType = OWCChartType.ColumnClustered;
                    }
                    if (this.rblChartType.SelectedValue.ToUpper() == ChartStyle.Line.ToUpper())
                    {
                        //this.OWCChartSpace1.ChartType = OWCChartType.Line;
                        this.OWCChartSpace1.ChartType = OWCChartType.LineMarkers;
                    }
                    this.OWCPivotTable1.Display = false;
                    this.OWCChartSpace1.Display = true;
                }
            }
        }
Exemplo n.º 22
0
 public void SetTimingType(TimingType newTimingType)
 {
     timingType = newTimingType;
 }