public void GetDataToExport()
        {
            try
            {
                string dataGridID      = Helper.Request(this, "DataGridID");
                string sortField       = Helper.Request(this, "SortField");
                string sortOrder       = Helper.Request(this, "SortOrder");
                string exportType      = Helper.Request(this, "ExportType");
                string searchFiletrs   = Helper.Request(this, "SearchFiletrs");
                string serializeObject = Helper.Request(this, "SerializeObject");
                string toolbarFilters  = Helper.Request(this, "ToolbarFilters");

                GeneralTools.DataGrid.DataGrid dataGrid = ((DataGridSchema)SerializationTools.DeserializeXml(Helper.Decrypt(serializeObject, HttpContext.Current.Session), typeof(DataGridSchema))).GetDataGrid();
                int pageControl = GetPageAssemblyValue(Request.Url.ToString());

                Assembly currentAssembly   = Assembly.GetExecutingAssembly();
                string   pageName          = string.Format("{0}.{1}", currentAssembly.GetName().Name, ((Business.UserControls)pageControl).ToString().Replace('_', '.'));
                Delegate dataBinderHandler = ((UIUserControlBase)Activator.CreateInstance(currentAssembly.GetType(pageName))).GetDataBinder(dataGrid.ID);
                Delegate dataRenderEvent   = ((UIUserControlBase)Activator.CreateInstance(currentAssembly.GetType(pageName))).GetDataRenderHandler(dataGrid.ID);

                string fileName = string.Empty;
                switch (exportType.ToLower())
                {
                case "pdf":
                    fileName = dataGrid.ExportToPdfFile(sortField, sortOrder, searchFiletrs, toolbarFilters, dataBinderHandler, dataRenderEvent);
                    byte[] data = File.ReadAllBytes(fileName);
                    Response.BinaryWrite(data);
                    Response.ContentType = "application/pdf";
                    Response.AppendHeader("content-disposition", "attachment;filename=export.pdf");
                    Response.End();
                    break;

                case "excel":
                    Response.Clear();
                    Response.AddHeader("content-disposition", "attachment;filename=Test.xls");
                    Response.ContentType     = "application/ms-excel";
                    Response.ContentEncoding = System.Text.Encoding.Unicode;
                    Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());

                    System.IO.StringWriter stringWriter = new System.IO.StringWriter();
                    string style = @"<style> .textmode { mso-number-format:\@;} </style>";
                    Response.Write(style);
                    stringWriter.Write(dataGrid.ExportToExcel(sortField, sortOrder, searchFiletrs, toolbarFilters, dataBinderHandler, dataRenderEvent));

                    System.Web.UI.HtmlTextWriter htmlTextWriter = new System.Web.UI.HtmlTextWriter(stringWriter);
                    this.RenderControl(htmlTextWriter);

                    Response.Write(stringWriter.ToString());
                    Response.End();
                    break;
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                Response.End();
            }
        }
        public static DataGridResult GetDataInfo(string serializeObject, string c, string _search, string nd, int rows, int page, string sidx, string sord)
        {
            int pageControl = GetPageAssemblyValue(c);

            if (!CheckUserLogin(Helper.GetString(pageControl)))
            {
                Session["SessionExpired"] = true;
                throw new Exception("[{(SessionExpired)}]");
            }

            DataGrid dataGrid = ((DataGridSchema)SerializationTools.DeserializeXml(Helper.Decrypt(serializeObject, HttpContext.Current.Session), typeof(DataGridSchema))).GetDataGrid();

            string searchFiletrs  = string.Empty;
            string toolbarFilters = string.Empty;

            if (_search == "True")
            {
                string searchOptions = "[" + Helper.GetStreamContent(System.Web.HttpContext.Current.Request.InputStream) + "]";
                JArray array         = JArray.Parse(searchOptions);
                foreach (JObject content in array.Children <JObject>())
                {
                    foreach (JProperty prop in content.Properties())
                    {
                        if (prop.Name == "filters")
                        {
                            toolbarFilters = JObject.Parse(prop.Value.ToString())["rules"].ToString();
                        }
                        if (prop.Name == "SearchFiletrs")
                        {
                            searchFiletrs = prop.Value.ToString();
                        }
                    }
                }
            }

            Assembly currentAssembly   = Assembly.GetExecutingAssembly();
            string   pageName          = string.Format("{0}.{1}", currentAssembly.GetName().Name, ((Business.UserControls)pageControl).ToString().Replace('_', '.'));
            Delegate dataBinderHandler = ((UIUserControlBase)Activator.CreateInstance(currentAssembly.GetType(pageName))).GetDataBinder(dataGrid.ID);
            Delegate dataRenderEvent   = ((UIUserControlBase)Activator.CreateInstance(currentAssembly.GetType(pageName))).GetDataRenderHandler(dataGrid.ID);

            return(dataGrid.DataBind(sidx, sord, page, rows, searchFiletrs, toolbarFilters, dataBinderHandler, dataRenderEvent));
        }
예제 #3
0
        private void InitializePage()
        {
            btnSave.Attributes["onclick"] = "return submitValidation();";
            btnSave.Text   = Language.GetString(btnSave.Text);
            btnCancel.Text = Language.GetString(btnCancel.Text);

            drpNumber.DataSource     = Facade.PrivateNumber.GetUserPrivateNumbersForReceive(UserGuid);
            drpNumber.DataTextField  = "Number";
            drpNumber.DataValueField = "Guid";
            drpNumber.DataBind();

            foreach (SmsFilterSenderNumber senderNumber in Enum.GetValues(typeof(SmsFilterSenderNumber)))
            {
                drpTypeConditionSender.Items.Add(new ListItem(Language.GetString(senderNumber.ToString()), ((int)senderNumber).ToString()));
            }
            drpTypeConditionSender.Items.Insert(0, new ListItem(string.Empty, string.Empty));

            foreach (SmsFilterConditions condition in Enum.GetValues(typeof(SmsFilterConditions)))
            {
                drpConditions.Items.Add(new ListItem(Language.GetString(condition.ToString()), ((int)condition).ToString()));
            }

            foreach (SmsFilterOperations operation in Enum.GetValues(typeof(SmsFilterOperations)))
            {
                drpOperations.Items.Add(new ListItem(Language.GetString(operation.ToString()), ((int)operation).ToString()));
            }
            drpOperations.Items.Insert(0, new ListItem(string.Empty, string.Empty));

            drpSenderNumber.DataSource     = Facade.PrivateNumber.GetUserPrivateNumbersForSend(UserGuid);
            drpSenderNumber.DataTextField  = "Number";
            drpSenderNumber.DataValueField = "Guid";
            drpSenderNumber.DataBind();
            drpSenderNumber.Items.Insert(0, new ListItem(Language.GetString("SenderNumber"), string.Empty));

            DataTable dtUserFormats = Facade.SmsFormat.GetUserSmsFormats(UserGuid);

            drpAccpetFormat.DataSource     = dtUserFormats;
            drpAccpetFormat.DataTextField  = "FormatName";
            drpAccpetFormat.DataValueField = "FormatGuid";
            drpAccpetFormat.DataBind();
            drpAccpetFormat.Items.Insert(0, new ListItem(Language.GetString("UseFormatIfMatching"), string.Empty));

            drpRejectFormat.DataSource     = dtUserFormats;
            drpRejectFormat.DataTextField  = "FormatName";
            drpRejectFormat.DataValueField = "FormatGuid";
            drpRejectFormat.DataBind();
            drpRejectFormat.Items.Insert(0, new ListItem(Language.GetString("UseFormatIncompatibility"), string.Empty));

            int resultCount = 0;

            drpTrafficRelay.DataSource     = Facade.TrafficRelay.GetPagedTrafficRelays(UserGuid, "CreateDate", 0, 0, ref resultCount);
            drpTrafficRelay.DataTextField  = "Url";
            drpTrafficRelay.DataValueField = "Guid";
            drpTrafficRelay.DataBind();

            dtpStartDate.Date = DateManager.GetSolarDate(DateTime.Now);
            dtpStartDate.Time = DateTime.Now.TimeOfDay.ToString();

            dtpEndDate.Date = DateManager.GetSolarDate(DateTime.Now);
            dtpEndDate.Time = DateTime.Now.TimeOfDay.ToString();

            if (ActionType == "edit")
            {
                Common.SmsParser           smsParser = Facade.SmsParser.LoadSmsParser(SmsParserGuid);
                ParserFormulaSerialization parserFormulaSerialization = new ParserFormulaSerialization();

                drpNumber.SelectedValue = smsParser.PrivateNumberGuid.ToString();
                txtTitle.Text           = smsParser.Title;
                dtpStartDate.Date       = DateManager.GetSolarDate(smsParser.FromDateTime);
                dtpStartDate.Time       = smsParser.FromDateTime.TimeOfDay.ToString();
                dtpEndDate.Date         = DateManager.GetSolarDate(smsParser.ToDateTime);
                dtpEndDate.Time         = smsParser.ToDateTime.TimeOfDay.ToString();
                hdnScopeGuid.Value      = smsParser.Scope.ToString();
                drpTypeConditionSender.SelectedValue = smsParser.TypeConditionSender.ToString();
                txtConditionSender.Text = smsParser.ConditionSender;

                DataTable dataTableParserFormulas = Facade.ParserFormula.GetParserFormulas(SmsParserGuid);
                if (dataTableParserFormulas.Rows.Count > 0)
                {
                    DataRow row = dataTableParserFormulas.Rows[0];
                    drpConditions.SelectedValue = row["Condition"].ToString();
                    txtCondition.Text           = row["Key"].ToString();

                    string reactionExtension = row["ReactionExtention"].ToString();
                    parserFormulaSerialization  = (ParserFormulaSerialization)SerializationTools.DeserializeXml(reactionExtension, typeof(ParserFormulaSerialization));
                    drpOperations.SelectedValue = parserFormulaSerialization.Condition.ToString();
                    switch (parserFormulaSerialization.Condition)
                    {
                    case (int)SmsFilterOperations.AddToGroup:
                    case (int)SmsFilterOperations.RemoveFromGroup:
                        hdnOperationGroupGuid.Value   = parserFormulaSerialization.ReferenceGuid.ToString();
                        drpSenderNumber.SelectedValue = parserFormulaSerialization.Sender.ToString();
                        txtSmsBody.Text = parserFormulaSerialization.Text;
                        txtUrl.Text     = parserFormulaSerialization.VasURL;
                        break;

                    case (int)SmsFilterOperations.SendSmsToGroup:
                        txtSmsBody.Text = parserFormulaSerialization.Text;
                        drpSenderNumber.SelectedValue = parserFormulaSerialization.Sender.ToString();
                        hdnGroupGuid.Value            = parserFormulaSerialization.ReferenceGuid.ToString();
                        break;

                    case (int)SmsFilterOperations.SendSmsToSender:
                        txtSmsBody.Text = parserFormulaSerialization.Text;
                        drpSenderNumber.SelectedValue = parserFormulaSerialization.Sender.ToString();
                        break;

                    case (int)SmsFilterOperations.TransferToUrl:
                        drpTrafficRelay.SelectedValue = parserFormulaSerialization.ReferenceGuid.ToString();
                        break;

                    case (int)SmsFilterOperations.TransferToMobile:
                        txtOpration.Text = parserFormulaSerialization.Text;
                        drpSenderNumber.SelectedValue = parserFormulaSerialization.Sender.ToString();
                        break;

                    case (int)SmsFilterOperations.SendSmsFromFormat:
                        drpRejectFormat.SelectedValue = parserFormulaSerialization.RejectFormatGuid.ToString();
                        drpAccpetFormat.SelectedValue = parserFormulaSerialization.AcceptFormatGuid.ToString();
                        drpSenderNumber.SelectedValue = parserFormulaSerialization.Sender.ToString();
                        break;

                    case (int)SmsFilterOperations.ForwardSmsToGroup:
                        drpSenderNumber.SelectedValue = parserFormulaSerialization.Sender.ToString();
                        hdnOperationGroupGuid.Value   = parserFormulaSerialization.ReferenceGuid.ToString();
                        break;

                    default:
                        txtOpration.Text = parserFormulaSerialization.Text;
                        break;
                    }
                }

                ClientSideScript = "setOption();setCondition('edit');";
            }
        }