Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                EntityId = Request.QueryString["id"] == null ? Guid.Empty : new Guid(Request.QueryString["id"]);
                string OrgName = Request.QueryString["orgname"] == null ? "" : Request.QueryString["orgname"];
                EntityType = Request.QueryString["type"] == null ? 0 : int.Parse(Request.QueryString["type"]);
                EntityName = Request.QueryString["typename"] == null ? "" : Request.QueryString["typename"];

                string data = Request.QueryString["data"] == null ? "" : Request.QueryString["data"];
                if (EntityId != Guid.Empty && EntityType != 0 && OrgName != "" && data != "")
                {
                    CreateService(ConfigurationManager.AppSettings["ServerName"], OrgName, ConfigurationManager.AppSettings["Login"],
                                  ConfigurationManager.AppSettings["Password"], ConfigurationManager.AppSettings["Domain"]);
                    try
                    {
                        string LicenseFilePath = ConfigurationManager.AppSettings["LicenseFilePath"];
                        // Check for license and apply if exists
                        if (File.Exists(LicenseFilePath))
                        {
                            License license = new License();
                            license.SetLicense(LicenseFilePath);
                        }
                    }
                    catch { }
                    string[] ButtonsData = data.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string ButtonData in ButtonsData)
                    {
                        string[] Data = ButtonData.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                        if (Data.Length == 4)
                        {
                            string TemplateName    = Data[0];
                            string ButtonToDisplay = Data[1];

                            if (ButtonToDisplay.ToLower() == "download")
                            {
                                BTN_Download.Visible = true;
                                DownloadTemplate     = TemplateName;
                                DownloadFormat       = Data[2];
                                DownloadFileName     = Data[3];
                            }
                            if (ButtonToDisplay.ToLower() == "note")
                            {
                                BTN_AttachToNote.Visible = true;
                                AttachToNoteTemplate     = TemplateName;
                                AttachToNoteFormat       = Data[2];
                                AttachToNoteFileName     = Data[3];
                            }
                        }
                        else
                        {
                            LBL_Message.Text         = "Data is not correct.";
                            BTN_Download.Visible     = false;
                            BTN_AttachToNote.Visible = false;
                            LBL_Message.Visible      = true;
                        }
                    }
                }
                else
                {
                    LBL_Message.Text         = "Parameters are not correct, Please save the record first.";
                    BTN_Download.Visible     = false;
                    BTN_AttachToNote.Visible = false;
                    LBL_Message.Visible      = true;
                }
            }
            catch (Exception ex)
            {
                LBL_Message.Text         = "Error has occured. Details: " + ex.Message;
                BTN_Download.Visible     = false;
                BTN_AttachToNote.Visible = false;
                LBL_Message.Visible      = true;
            }
        }