Exemplo n.º 1
0
        protected void BtnGetResult_Click(object sender, EventArgs e)
        {
            ArrayList arrExtraAttachment = null;
            bool flag = false;
            bool active = true;
            if (String.IsNullOrEmpty(WebAccessCodeTextBox.Text))
            {
                this.ErrorLabel.Text = GetLocalResourceObject("ErrorLabelText").ToString();
            }
            else
            {
                try
                {
                    ResultServiceClient client =  new ResultServiceClient();
                    string login = "", pass = "";
                    login = ConfigurationManager.AppSettings["loginForService"];
                    pass = ConfigurationManager.AppSettings["passwordForService"];

                    client.ClientCredentials.Windows.ClientCredential.UserName = login;
                    client.ClientCredentials.Windows.ClientCredential.Password = pass;

                    var resultSummary = client.GetResultSummaryByWebCode(WebAccessCodeTextBox.Text);
                    if (resultSummary == null)
                    {
                        this.StatusLabel.ForeColor = System.Drawing.Color.Red;
                        this.StatusLabel.Text = GetLocalResourceObject("StatusLabelOrderIsNotFound").ToString();
                    }
                    else
                    {
                        this.StatusLabel.Text = null;

                        if ((resultSummary.Results.Count() > 0) && (resultSummary.IsFinal == true)) // ваш заказ готов результаты есть
                        {
                            this.StatusLabel.ForeColor = System.Drawing.Color.Green;
                            this.StatusLabel.Text = GetLocalResourceObject("StatusLabelReady").ToString();
                        }
                        if ((resultSummary.Results.Count() > 0) && (resultSummary.IsFinal == false)) // ваш заказ не готов показаны предварительные результаты
                        {
                            this.StatusLabel.ForeColor = System.Drawing.Color.Red;
                            this.StatusLabel.Text = GetLocalResourceObject("StatusLabelNotReady").ToString();
                        }
                        if ((resultSummary.Results.Count() == 0) && (resultSummary.IsFinal == true)) // по вашему заказу нет результатов, заказ закрыт
                        {
                            this.StatusLabel.ForeColor = System.Drawing.Color.Red;
                            this.StatusLabel.Text = GetLocalResourceObject("StatusLabelPerezabor").ToString();
                            return;
                        }
                        if ((resultSummary.Results.Count() == 0) && (resultSummary.IsFinal == false)) // по вашему заказу нет результатов
                        {
                            this.StatusLabel.ForeColor = System.Drawing.Color.Red;
                            this.StatusLabel.Text = GetLocalResourceObject("StatusLabelNotResult").ToString();
                            return;
                        }

                        this.PanelResult.Visible = true;
                        Session.RemoveAll();
                        Session["barcode"] = resultSummary.Barcode.ToString();
                        foreach (var result in resultSummary.Results)
                        {
                            if (String.Equals("SilabMainResult", result.Type.ToString()))
                            {
                                Session["SilabMainResultUri"] = result.ServiceUri;
                                this.tabPanelMainResult.Style["display"] = "inline-block";
                                if (string.IsNullOrEmpty(this.tabPanelMainResult.Attributes["class"]))
                                {

                                }
                                else
                                {
                                    var newClassValue = this.panelMainResult.Attributes["class"].Replace("tab-pane fade in active", "tab-pane fade");
                                    this.panelMainResult.Attributes["class"] = newClassValue;
                                    this.tabPanelMainResult.Attributes.Remove("class");
                                }
                                if (active)
                                {
                                    var newClassValue = this.panelMainResult.Attributes["class"].Replace("tab-pane fade", "tab-pane fade in active");
                                    this.panelMainResult.Attributes["class"] = newClassValue;
                                    this.tabPanelMainResult.Attributes.Add("class", "active");
                                    active = false;
                                }

                            }
                            else
                            if (String.Equals("SilabMicroResult", result.Type.ToString()))
                            {
                                Session["SilabMicroResultUri"] = result.ServiceUri;
                                this.tabPanelMicroResult.Style["display"] = "inline-block";
                                if (string.IsNullOrEmpty(this.tabPanelMicroResult.Attributes["class"]))
                                {

                                }
                                else
                                {
                                    var newClassValue = this.panelMicroResult.Attributes["class"].Replace("tab-pane fade in active", "tab-pane fade");
                                    this.panelMicroResult.Attributes["class"] = newClassValue;
                                    this.tabPanelMicroResult.Attributes.Remove("class");
                                }
                                if (active)
                                {
                                    var newClassValue = this.panelMicroResult.Attributes["class"].Replace("tab-pane fade", "tab-pane fade in active");
                                    this.panelMicroResult.Attributes["class"] = newClassValue;
                                    this.tabPanelMicroResult.Attributes.Add("class", "active");
                                    active = false;
                                }
                            }
                            else
                            if (String.Equals("ExtraAttachment", result.Type.ToString()))
                            {
                                if (flag == false)
                                {
                                    arrExtraAttachment = new ArrayList();
                                }
                                flag = true;
                                arrExtraAttachment.Add(result.ServiceUri);
                                this.tabPanelExtraAttachmentResult.Style["display"] = "inline-block";
                                if (string.IsNullOrEmpty(this.tabPanelExtraAttachmentResult.Attributes["class"]))
                                {

                                }
                                else
                                {
                                    var newClassValue = this.panelExtraAttachmentResult.Attributes["class"].Replace("tab-pane fade in active", "tab-pane fade");
                                    this.panelExtraAttachmentResult.Attributes["class"] = newClassValue;
                                    this.tabPanelExtraAttachmentResult.Attributes.Remove("class");
                                }
                                if (active)
                                {
                                    var newClassValue = this.panelExtraAttachmentResult.Attributes["class"].Replace("tab-pane fade", "tab-pane fade in active");
                                    this.panelExtraAttachmentResult.Attributes["class"] = newClassValue;
                                    this.tabPanelExtraAttachmentResult.Attributes.Add("class", "active");
                                    active = false;
                                }
                            }
                        }
                        if (flag)
                        {
                            Session["ExtraAttachmentUri"] = arrExtraAttachment;
                        }
                        if (resultSummary.Results.Length >= 2)
                        {
                            this.ResultAll.Text = GetLocalResourceObject("ResultAllText").ToString();
                            this.rowResultAllLabel.Style["display"] = "block";
                        }
                    }
                    client.Close();
                }
                catch (Exception ex)
                {
                    this.StatusLabel.ForeColor = System.Drawing.Color.Red;
                    this.StatusLabel.Text = GetLocalResourceObject("StatusLabelExeption").ToString();
                    logger.Error(ex.Message +" | Row: " + ex.StackTrace.Substring(ex.StackTrace.LastIndexOf(' ')) + " | CodeForWebFFSOrder: " + WebAccessCodeTextBox.Text);
                }
            }
        }
Exemplo n.º 2
0
        private void GetResult()
        {
            ArrayList arrExtraAttachment = null;
            bool      flag   = false;
            bool      active = true;

            try
            {
                ResultServiceClient client = new ResultServiceClient();
                string login = "", pass = "";
                login = ConfigurationManager.AppSettings["loginForService"];
                pass  = ConfigurationManager.AppSettings["passwordForService"];

                client.ClientCredentials.Windows.ClientCredential.UserName = login;
                client.ClientCredentials.Windows.ClientCredential.Password = pass;

                var resultSummary = client.GetResultSummaryByWebCode(WebAccessCodeTextBox.Text);
                this.logger.Trace("CodeForWebFFSOrder: " + WebAccessCodeTextBox.Text + " | IP-адрес: " + HttpContext.Current.Request.UserHostAddress);
                if (resultSummary == null)
                {
                    this.StatusLabel.ForeColor         = System.Drawing.Color.Red;
                    this.StatusLabel.Text              = GetLocalResourceObject("StatusLabelOrderIsNotFound").ToString();
                    Session["numberIncorrectPassword"] = Convert.ToInt32(Session["numberIncorrectPassword"]) + 1;
                }
                else
                {
                    this.StatusLabel.Text = null;
                    if ((resultSummary.Results.Count() > 0) && (resultSummary.IsFinal == true)) // ваш заказ готов результаты есть
                    {
                        this.StatusLabel.ForeColor = System.Drawing.Color.Green;
                        this.StatusLabel.Text      = GetLocalResourceObject("StatusLabelReady").ToString();
                    }
                    if ((resultSummary.Results.Count() > 0) && (resultSummary.IsFinal == false)) // ваш заказ не готов показаны предварительные результаты
                    {
                        this.StatusLabel.ForeColor = System.Drawing.Color.Red;
                        this.StatusLabel.Text      = GetLocalResourceObject("StatusLabelNotReady").ToString();
                    }
                    if ((resultSummary.Results.Count() == 0) && (resultSummary.IsFinal == true)) // по вашему заказу нет результатов, заказ закрыт
                    {
                        this.StatusLabel.ForeColor = System.Drawing.Color.Red;
                        this.StatusLabel.Text      = GetLocalResourceObject("StatusLabelPerezabor").ToString();
                        logger.Error(this.StatusLabel.Text + " | CodeForWebFFSOrder: " + WebAccessCodeTextBox.Text);
                        return;
                    }
                    if ((resultSummary.Results.Count() == 0) && (resultSummary.IsFinal == false)) // по вашему заказу нет результатов
                    {
                        this.StatusLabel.ForeColor = System.Drawing.Color.Red;
                        this.StatusLabel.Text      = GetLocalResourceObject("StatusLabelNotResult").ToString();
                        return;
                    }
                    this.PanelResult.Visible = true;
                    Session.RemoveAll();
                    Session["barcode"] = resultSummary.Barcode.ToString();
                    int countExtraAttachment = 1;
                    foreach (var result in resultSummary.Results)
                    {
                        if (String.Equals("SilabMainResult", result.Type.ToString()))
                        {
                            Session["SilabMainResultUri"]            = result.ServiceUri;
                            this.tabPanelMainResult.Style["display"] = "inline-block";
                            this.DownloadResultMain.Style["display"] = "inline-block";

                            if (string.IsNullOrEmpty(this.tabPanelMainResult.Attributes["class"]))
                            {
                            }
                            else
                            {
                                var newClassValue = this.panelMainResult.Attributes["class"].Replace("tab-pane fade in active", "tab-pane fade");
                                this.panelMainResult.Attributes["class"] = newClassValue;
                                this.tabPanelMainResult.Attributes.Remove("class");
                            }
                            if (active)
                            {
                                var newClassValue = this.panelMainResult.Attributes["class"].Replace("tab-pane fade", "tab-pane fade in active");
                                this.panelMainResult.Attributes["class"] = newClassValue;
                                this.tabPanelMainResult.Attributes.Add("class", "active");
                                active = false;
                            }
                        }
                        else
                        if (String.Equals("SilabMicroResult", result.Type.ToString()))
                        {
                            Session["SilabMicroResultUri"]            = result.ServiceUri;
                            this.tabPanelMicroResult.Style["display"] = "inline-block";
                            this.DownloadResultMicro.Style["display"] = "inline-block";
                            //this.panelMicroResult.Style["display"] = "block";

                            if (string.IsNullOrEmpty(this.tabPanelMicroResult.Attributes["class"]))
                            {
                            }
                            else
                            {
                                var newClassValue = this.panelMicroResult.Attributes["class"].Replace("tab-pane fade in active", "tab-pane fade");
                                this.panelMicroResult.Attributes["class"] = newClassValue;
                                this.tabPanelMicroResult.Attributes.Remove("class");
                            }
                            if (active)
                            {
                                var newClassValue = this.panelMicroResult.Attributes["class"].Replace("tab-pane fade", "tab-pane fade in active");
                                this.panelMicroResult.Attributes["class"] = newClassValue;
                                this.tabPanelMicroResult.Attributes.Add("class", "active");
                                active = false;
                            }
                        }
                        else
                        if (String.Equals("ExtraAttachment", result.Type.ToString()))
                        {
                            if (flag == false)
                            {
                                arrExtraAttachment = new ArrayList();
                            }
                            flag = true;
                            arrExtraAttachment.Add(result.ServiceUri);
                            if (countExtraAttachment == 1)
                            {
                                this.tabPanelExtraAttachmentResult.Style["display"] = "inline-block";
                                this.DownloadResultExtraAttachment.Style["display"] = "inline-block";
                            }
                            if (countExtraAttachment == 2)
                            {
                                this.tabPanelExtraAttachmentResult2.Style["display"] = "inline-block";
                                this.DownloadResultExtraAttachment2.Style["display"] = "inline-block";
                            }
                            if (countExtraAttachment == 3)
                            {
                                this.tabPanelExtraAttachmentResult3.Style["display"] = "inline-block";
                                this.DownloadResultExtraAttachment3.Style["display"] = "inline-block";
                            }
                            if (countExtraAttachment == 4)
                            {
                                this.tabPanelExtraAttachmentResult4.Style["display"] = "inline-block";
                                this.DownloadResultExtraAttachment4.Style["display"] = "inline-block";
                            }
                            if (countExtraAttachment == 5)
                            {
                                this.tabPanelExtraAttachmentResult5.Style["display"] = "inline-block";
                                this.DownloadResultExtraAttachment5.Style["display"] = "inline-block";
                            }
                            countExtraAttachment++;

                            if (string.IsNullOrEmpty(this.tabPanelExtraAttachmentResult.Attributes["class"]))
                            {
                            }
                            else
                            {
                                var newClassValue = this.panelExtraAttachmentResult.Attributes["class"].Replace("tab-pane fade in active", "tab-pane fade");
                                this.panelExtraAttachmentResult.Attributes["class"] = newClassValue;
                                this.tabPanelExtraAttachmentResult.Attributes.Remove("class");
                            }
                            if (active)
                            {
                                var newClassValue = this.panelExtraAttachmentResult.Attributes["class"].Replace("tab-pane fade", "tab-pane fade in active");
                                this.panelExtraAttachmentResult.Attributes["class"] = newClassValue;
                                this.tabPanelExtraAttachmentResult.Attributes.Add("class", "active");
                                active = false;
                            }
                        }
                    }
                    if (flag)
                    {
                        Session["ExtraAttachmentUri"] = arrExtraAttachment;
                    }
                    if (resultSummary.Results.Length >= 2)
                    {
                        this.ResultAll.Text = GetLocalResourceObject("ResultAllText").ToString();
                        this.rowResultAllLabel.Style["display"] = "block";
                    }
                }
                if (Convert.ToInt32(Session["numberIncorrectPassword"]) == 5)
                {
                    this.Recaptcha.Style["display"] = "block";
                    this.StatusLabel.Text           = null;
                }
                client.Close();
            }
            catch (Exception ex)
            {
                this.StatusLabel.ForeColor = System.Drawing.Color.Red;
                this.StatusLabel.Text      = GetLocalResourceObject("StatusLabelExeption").ToString();
                logger.Error(ex.Message + " | Row: " + ex.StackTrace.Substring(ex.StackTrace.LastIndexOf(' ')) + " | CodeForWebFFSOrder: " + WebAccessCodeTextBox.Text);
            }
        }