Exemple #1
0
        public void Edit_POST()
        {
            string bindedDomains;

            var entity = EntityForm.GetEntity <SiteDto>();

            entity.Domain = Regex.Replace(entity.Domain, "\\s+|,+", " ");      //将多个空白替换成一个

            if (this.CheckDomainBind(entity.SiteId, entity.Domain, out bindedDomains))
            {
                base.RenderError("以下域名已被绑定:<br />" + bindedDomains.Replace("\n", "<br />"));
            }
            else
            {
                ServiceCall.Instance.SiteService.SaveSite(entity);
                base.RenderSuccess("站点保存成功!");
            }
        }
Exemple #2
0
        public void Create_GET()
        {
            var site  = new SiteDto();
            var sites = SiteCacheManager.GetAllSites();

            if (sites.Count > 0)
            {
                site.SiteId = sites[sites.Count - 1].SiteId + 1;
                //site.Name = "未命名站点"+site.SiteId.ToString();
            }
            string html = EntityForm.Build <SiteDto>(site, true, "创建");

            base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Site_Edit), new
            {
                form = html,
                tpls = Helper.GetTemplateOptions("")
            });
        }
Exemple #3
0
        public string SaveReleatedLink_POST()
        {
            try
            {
                LinkDto link;
                link = EntityForm.GetEntity <LinkDto>();

                ServiceCall.Instance.ContentService.SaveRelatedLink(
                    this.SiteId,
                    Request["typeIndent"],
                    int.Parse(Request["contentId"]),
                    link
                    );
                return(base.ReturnSuccess(link.LinkID == 0 ? "添加成功" : "保存成功"));
            }catch (Exception exc)
            {
                return(base.ReturnError(exc.Message));
            }
        }
Exemple #4
0
        void menu_loadToExistDetailWindow_Click(object sender, EventArgs e)
        {
            if (this.listView_browse.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未选定要装入种册窗的事项");
                return;
            }
            string strPath = this.listView_browse.SelectedItems[0].SubItems[0].Text;

            EntityForm form = Program.MainForm.GetTopChildWindow <EntityForm>();

            if (form == null)
            {
                MessageBox.Show(this, "目前并没有已经打开的种册窗");
                return;
            }
            Global.Activate(form);
            form.LoadRecordOld(strPath, "", true);
        }
Exemple #5
0
        public void Create()
        {
            var site  = new SiteDto();
            var sites = SiteCacheManager.GetAllSites();

            if (sites.Count > 0)
            {
                site.SiteId = sites[sites.Count - 1].SiteId + 1;
            }
            //site.Name = "未命名站点"+site.SiteId.ToString();
            var html = EntityForm.Build <SiteDto>(site);

            RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Site_Edit), new
            {
                form     = html,
                post_url = "?module=site&action=create",
                tpls     = Helper.GetTemplateOptions("")
            });
        }
Exemple #6
0
        public string Save_POST()
        {
            var  entity      = EntityForm.GetEntity <SiteDto>();
            bool siteIsExist = ServiceCall.Instance.SiteService.CheckSiteExists(entity.SiteId);

            try
            {
                entity = CheckSiteEntity(siteIsExist, entity);
                if (!siteIsExist)
                {
                    entity.SiteId = 0;
                }
                ServiceCall.Instance.SiteService.SaveSite(entity);
            }
            catch (Exception exc)
            {
                return(base.ReturnError(exc.Message));
            }
            return(base.ReturnSuccess(siteIsExist ? "站点保存成功!" : "站点创建成功!"));
        }
Exemple #7
0
        // 打开到 种册窗
        void menuItem_loadToEntityForm_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.dpTable_items.SelectedRows.Count == 0)
            {
                strError = "尚未选定要打开的册事项";
                goto ERROR1;
            }

            DpRow  selected_row   = this.dpTable_items.SelectedRows[0];
            string strItemBarcode = selected_row[COLUMN_ITEMBARCODE].Text;

            if (string.IsNullOrEmpty(strItemBarcode) == true)
            {
                strError = "所选定的册事项不具备册条码号信息";
                goto ERROR1;
            }

            EntityForm form = Program.MainForm.EnsureEntityForm();

            Global.Activate(form);

            if (strItemBarcode.StartsWith("@biblioRecPath:") == true)
            {
                form.LoadRecordOld(strItemBarcode.Substring("@biblioRecPath:".Length), "", true);
            }
            else
            {
                form.LoadItemByBarcode(strItemBarcode, false);
            }

            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
        private EntityForm InitEntityForm(Guid guid)
        {
            var entityForm = new EntityForm
            {
                ID                     = string.Format("EntityFormControl_{0:N}", guid),
                FormCssClass           = "crmEntityFormView",
                PreviousButtonCssClass = "btn btn-default",
                NextButtonCssClass     = "btn btn-primary",
                SubmitButtonCssClass   = "btn btn-primary",
                ClientIDMode           = ClientIDMode.Static
            };

            int languageCode;

            if (TryGetLanguageCode(out languageCode))
            {
                entityForm.LanguageCode = languageCode;
                SetPortalName(entityForm, languageCode);
            }

            entityForm.EntityFormReference = new EntityReference("adx_entityform", guid);
            entityForm.ItemSaved          += OnItemSaved;
            return(entityForm);
        }
        public override Panel ShowAddForm(object Object = null)
        {
            publisher EditPublisher = (publisher)Object;
            bool      EditState     = EditPublisher != null;

            ClearAllFields();
            //  UpdateList();
            Button BtnAdd = new Button()
            {
                Text = "Add"
            };

            BtnAdd.Click += (e, o) =>
            {
                publisher Publisher = new publisher()
                {
                    id      = EditState ? InputID.Text : null,
                    name    = InputPublisherName.Text.Trim(),
                    contact = InputContact.Text.Trim(),
                    address = InputAddress.Text.Trim(),
                    books   = null
                };
                if (null != UserClient.AddPublisher(Publisher, AppUser))
                {
                    MessageBox.Show("Success");
                    EntityForm.Navigate(0, 0);
                }
                else
                {
                    MessageBox.Show("Failed");
                }
            };
            InputID.Enabled = false;
            InputID.Text    = "GENERATED";

            if (EditState)
            {
                InputID.Text            = EditPublisher.id;
                InputPublisherName.Text = EditPublisher.name.Trim();
                InputAddress.Text       = EditPublisher.address.Trim();
                InputContact.Text       = EditPublisher.contact.Trim();
            }

            Control[] Controls = new Control[]
            {
                new TitleLabel(20)
                {
                    Text = "Add Publisher"
                }, new BlankControl(),
                new Label()
                {
                    Text = "ID"
                }, InputID,
                new Label()
                {
                    Text = "Name"
                }, InputPublisherName,
                new Label()
                {
                    Text = "Contact"
                }, InputContact,
                new Label()
                {
                    Text = "Address"
                }, InputAddress,
                BtnAdd, null
            };

            return(ControlUtil.GeneratePanel(2, Controls, 5, 180, 30, Color.Aqua));
        }
 public void Initialize(string action, Type type, EntityForm form, string uniquePropertyName)
 {
     Initialize(action, type, form);
 }
Exemple #11
0
 public static T ParseEntity <T>(this IDictionary <string, StringValues> form) where T : new()
 {
     return(EntityForm.GetEntity <T>(form));
 }
Exemple #12
0
 internal void ShowForm2(EntityForm EntityForm, string ModuleName, string FreeFilter, object TransStartDate, object TransEndDate, object[] Parameters)
 {
 }
 public void Initialize(CommandInfo command, EntityForm form, string uniquePropertyName)
 {
     Initialize(command, form);
 }
        public void ShowForm2(EntityForm EntityForm,
                              string ReportName, string FreeFilter,
                              object TransStartDate, object TransEndDate,
                              object[] Parameters)
        {
            _ReportName = ReportName;
            _EntityForm = EntityForm;

            if (EntityForm.ModuleName.Length > 0 && BaseSecurity.CurrentLogin
                .CurrentRole.Length > 0)
            {
                ModuleAccess ma = BaseSecurity.GetModuleAccess(EntityForm.ModuleName);

                if (!ma.GetVariable <bool>(SecurityVarName.ReportDesignPrint, false))
                {
                    comboBoxEdit1.Properties.Buttons[2].Enabled = false;
                }
            }

            _Evaluator = BaseFactory.CreateInstance <Evaluator>();
            if (_ReportName.Contains("Laporan"))
            {
                Text = _ReportName;
            }
            else
            {
                Text = "Laporan " + _ReportName;
            }

            _FilterForm = BaseFactory.CreateInstance(
                _EntityForm.FilterFormType) as IFilterForm;
            if (_FilterForm == null)
            {
                XtraMessageBox.Show("Form Filter harus implement Interface IFilterForm !",
                                    "Error Filter", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                return;
            }
            _ShowViewForm = _FilterForm as IShowView;
            if (_ShowViewForm == null)
            {
                XtraMessageBox.Show("Form Filter harus implement Interface IShowView !",
                                    "Error Filter", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                return;
            }

            if (_EntityForm.FilterFormType == null || _FilterForm as ReportEntity != null)
            {
                splitContainerControl1.PanelVisibility = SplitPanelVisibility.Panel2;
            }
            else
            {
                XtraForm Frm = _FilterForm as XtraForm;
                if (Frm != null)
                {
                    InitFilterForm(Frm, xtraScrollableControl1,
                                   splitContainerControl1);
                }
                else
                {
                    QueryReportEntity(xtraScrollableControl1,
                                      splitContainerControl1);
                }
            }

            List <string> ListItems = DocPrintBrowseLayout
                                      .GetListLayout("F_" + _ReportName);

            if (ListItems.Count == 0)
            {
                if (re != null)
                {
                    Dictionary <string, object> Vars = new Dictionary <string, object>();
                    re.GetVariables(Vars);
                    SaveReportFromTemplateFolder("F_", ReportName,
                                                 ListItems, Vars);
                }
                else
                {
                    SaveReportFromTemplateFolder("F_", ReportName,
                                                 ListItems, _FilterForm != null ?
                                                 _FilterForm.FilterList : null);
                }
            }
            comboBoxEdit1.Properties.Items.AddRange(ListItems);

            string CurrBrowseLayoutId = string.Empty;
            bool   Tmp;

            DocDefault.GetDefaultLayout(_ReportName,
                                        out CurrBrowseLayoutId, out CurrPrintLayoutId, out Tmp);

            if (re != null)
            {
                ((IShowView)re).ShowView(Parameters);
            }
            else if (_ShowViewForm != null)
            {
                _ShowViewForm.ShowView(Parameters);
            }

            comboBoxEdit1.SelectedItem = CurrBrowseLayoutId;
            if (comboBoxEdit1.SelectedIndex < 0 && comboBoxEdit1.Properties.Items.Count > 0)
            {
                comboBoxEdit1.SelectedIndex = 0;
            }
            else
            {
                comboBoxEdit1_SelectedIndexChanged(null, null);
            }
            sbTotal.Caption = "Total Halaman: " +
                              printControl1.PrintingSystem.Pages.Count;
            ribbonStatusBar1.Refresh();
            printControl1.PrintingSystem.AfterChange += new DevExpress.XtraPrinting.ChangeEventHandler(PrintingSystem_AfterChange);
            Show();
            printControl1.Focus();
        }
Exemple #15
0
 public void ShowForm(EntityForm EntityForm, string ReportName)
 {
 }
 public void Initialize(Type type, EntityForm form)
 {
     Initialize(QueryStrings.Action, type, form);
 }
Exemple #17
0
        // 装载数据
        public override bool LoadData()
        {
            string strError = "";
            int    nRet     = 0;

            BiblioInfo info       = this.BiblioInfo;
            string     strRecPath = this.BiblioInfo.RecPath;

            if (string.IsNullOrEmpty(info.OldXml) == true)
            {
                lock (syncRoot)
                {
                    channel = this.Container.MainForm.GetChannel();
                }
                try
                {
                    // 显示 正在处理
                    this.HTML = GetWaitingHtml("正在获取书目记录 " + strRecPath);

                    ShowData();

                    string[] results     = null;
                    byte[]   baTimestamp = null;
                    // 获得书目记录
                    channel.Timeout = new TimeSpan(0, 0, 5);
                    long lRet = channel.GetBiblioInfos(
                        Stop,
                        strRecPath,
                        "",
                        new string[] { "xml" },   // formats
                        out results,
                        out baTimestamp,
                        out strError);
                    if (lRet == 0)
                    {
                        nRet     = -1;
                        strError = "获取书目记录 " + strRecPath + " 时出错: " + strError;
                    }
                    else if (lRet == -1)
                    {
                        nRet     = -1;
                        strError = "获取书目记录 " + strRecPath + " 时出错: " + strError;
                    }
                    else
                    {
                        if (results == null || results.Length == 0)
                        {
                            strError = "results error";
                            throw new Exception(strError);
                        }

                        // TODO: 对 BiblioInfo 的成员进行操作的时候,是否要 lock 一下对象?
                        string strXml = results[0];
                        info.OldXml    = strXml;
                        info.Timestamp = baTimestamp;
                        info.RecPath   = strRecPath;
                    }
                }
                finally
                {
                    LibraryChannel temp_channel = channel;
                    lock (syncRoot)
                    {
                        channel = null;
                    }
                    this.Container.MainForm.ReturnChannel(temp_channel);
                }
            }

            string strXml1  = "";
            string strHtml2 = "";
            string strXml2  = "";

            if (nRet == -1)
            {
                strHtml2 = HttpUtility.HtmlEncode(strError);
            }
            else
            {
                nRet = BiblioSearchForm.GetXmlHtml(info,
                                                   out strXml1,
                                                   out strXml2,
                                                   out strHtml2,
                                                   out strError);
                if (nRet == -1)
                {
                    throw new Exception(strError);
                }
            }

            this.HTML = "<html>" +
                        this.Container.MainForm.GetMarcHtmlHeadString(true) +
                        "<body>" +
                        strHtml2 +
                        EntityForm.GetTimestampHtml(info.Timestamp) +
                        "</body></html>";

            this.XML = BiblioSearchForm.MergeXml(strXml1, strXml2);

            return(true);
        }
Exemple #18
0
 public static void ShouldContainOnly(this RecognitionResult result, string entityName, string entityValue,
                                      string canonicalForm)
 {
     result.Entities.Should().Equal(
         new[]
     {
         RecognizedEntity.Value(EntityName.Value(entityName), EntityForm.Value(entityValue), EntityForm.Value(canonicalForm))
     });
 }
 public void Initialize(Type type, EntityForm form, string uniquePropertyName)
 {
     Initialize(QueryStrings.Action, type, form, uniquePropertyName);
 }
Exemple #20
0
        public void DisplayCodeItems(List <EditablePortalItem> items, bool isLegacyPortal)
        {
            IsLegacyPortal = isLegacyPortal;
            portalItems    = items;
            tvCodeItems.Nodes.Clear();
            var rootNodes = new Dictionary <Guid, TreeNode>();

            if (isLegacyPortal)
            {
                rootNodes.Add(Guid.Empty, new TreeNode("(Not website related)"));
            }

            var searchText    = txtSearch.Text.ToLower();
            var filteredItems = items.Where(i => searchText.Length == 0 ||
                                            i.Name.ToLower().Contains(searchText) ||
                                            chkSearchInContent.Checked &&
                                            i.Items.Any(i2 => i2.Content.ToLower().Contains(searchText)))
                                .ToList();

            if (!filteredItems.Any() && searchText.Length > 0)
            {
                txtSearch.BackColor = Color.LightCoral;
                return;
            }

            foreach (var item in filteredItems)
            {
                item.UpdateRequired += Item_UpdateRequired;
                var websiteReference = item.WebsiteReference;

                if (websiteReference == null)
                {
                    continue;
                }

                TreeNode parentNode;
                if (rootNodes.ContainsKey(websiteReference.Id))
                {
                    parentNode = rootNodes[websiteReference.Id];
                }
                else
                {
                    var name     = websiteReference.Id == Guid.Empty ? "(Not website related)" : websiteReference.Name;
                    var rootNode = new TreeNode(name);

                    rootNodes.Add(websiteReference.Id, rootNode);

                    parentNode = rootNode;

                    parentNode.Nodes.Add(new TreeNode("Web Pages")
                    {
                        Name = "WebPage"
                    });

                    if (!IsLegacyPortal)
                    {
                        parentNode.Nodes.Add(new TreeNode("Entity Forms")
                        {
                            Name = "EntityForm"
                        });
                        parentNode.Nodes.Add(new TreeNode("Entity Lists")
                        {
                            Name = "EntityList"
                        });
                        parentNode.Nodes.Add(new TreeNode("Web Forms")
                        {
                            Name = "WebForm"
                        });
                        parentNode.Nodes.Add(new TreeNode("Web Templates")
                        {
                            Name = "WebTemplate"
                        });
                    }

                    parentNode.Nodes.Add(new TreeNode("Web Files")
                    {
                        Name = "WebFile"
                    });
                }

                TreeNode typeNode;

                if (item is WebPage)
                {
                    typeNode = parentNode.Nodes["WebPage"];

                    WebPage page = (WebPage)item;
                    page.JavaScript.StateChanged += JavaScript_StateChanged;
                    page.Style.StateChanged      += JavaScript_StateChanged;

                    TreeNode node;
                    if (page.IsRoot || page.ParentPageId == Guid.Empty)
                    {
                        node = new TreeNode(page.Name)
                        {
                            Tag = item
                        };
                        typeNode.Nodes.Add(node);

                        if (isLegacyPortal)
                        {
                            var scriptNode = new TreeNode("JavaScript")
                            {
                                Tag = page.JavaScript
                            };
                            page.JavaScript.Node = scriptNode;
                            var styleNode = new TreeNode("Style")
                            {
                                Tag = page.Style
                            };
                            page.Style.Node = styleNode;

                            node.Nodes.Add(scriptNode);
                            node.Nodes.Add(styleNode);
                        }
                    }
                    else
                    {
                        var parentPageNode = typeNode.Nodes.Cast <TreeNode>().FirstOrDefault(t => ((WebPage)t.Tag).Id == page.ParentPageId);
                        if (parentPageNode == null)
                        {
                            continue;
                        }

                        node = new TreeNode(page.Language)
                        {
                            Tag = item
                        };

                        var scriptNode = new TreeNode("JavaScript")
                        {
                            Tag = page.JavaScript
                        };
                        page.JavaScript.Node = scriptNode;
                        var styleNode = new TreeNode("Style")
                        {
                            Tag = page.Style
                        };
                        page.Style.Node = styleNode;

                        node.Nodes.Add(scriptNode);
                        node.Nodes.Add(styleNode);

                        parentPageNode.Nodes.Add(node);
                    }
                }
                else if (item is EntityForm)
                {
                    typeNode = parentNode.Nodes["EntityForm"];

                    if (typeNode == null)
                    {
                        typeNode = new TreeNode("Entity Forms")
                        {
                            Name = "EntityForm"
                        };
                        rootNodes[item.WebsiteReference.Id].Nodes.Add(typeNode);
                    }

                    EntityForm form = (EntityForm)item;
                    form.JavaScript.StateChanged += JavaScript_StateChanged;

                    var node = new TreeNode(form.Name)
                    {
                        Tag = form.JavaScript
                    };
                    form.JavaScript.Node = node;

                    typeNode.Nodes.Add(node);
                }
                else if (item is EntityList)
                {
                    typeNode = parentNode.Nodes["EntityList"];

                    if (typeNode == null)
                    {
                        typeNode = new TreeNode("Entity Lists")
                        {
                            Name = "EntityList"
                        };
                        rootNodes[item.WebsiteReference.Id].Nodes.Add(typeNode);
                    }

                    EntityList list = (EntityList)item;
                    list.JavaScript.StateChanged += JavaScript_StateChanged;

                    var node = new TreeNode(list.Name)
                    {
                        Tag = list.JavaScript
                    };
                    list.JavaScript.Node = node;

                    typeNode.Nodes.Add(node);
                }
                else if (item is WebTemplate)
                {
                    typeNode = parentNode.Nodes["WebTemplate"];

                    if (typeNode == null)
                    {
                        typeNode = new TreeNode("Web Templates")
                        {
                            Name = "WebTemplate"
                        };
                        rootNodes[item.WebsiteReference.Id].Nodes.Add(typeNode);
                    }

                    WebTemplate template = (WebTemplate)item;
                    template.Code.StateChanged += JavaScript_StateChanged;

                    var node = new TreeNode(template.Name)
                    {
                        Tag = template.Code
                    };
                    template.Code.Node = node;

                    typeNode.Nodes.Add(node);
                }
                else if (item is WebFile)
                {
                    typeNode = parentNode.Nodes["WebFile"];

                    if (typeNode == null)
                    {
                        typeNode = new TreeNode("Web Files")
                        {
                            Name = "WebFile"
                        };
                        rootNodes[item.WebsiteReference.Id].Nodes.Add(typeNode);
                    }

                    WebFile file = (WebFile)item;
                    file.Code.StateChanged += JavaScript_StateChanged;

                    var node = new TreeNode(file.Name)
                    {
                        Tag = file.Code
                    };
                    file.Code.Node = node;

                    typeNode.Nodes.Add(node);
                }
                else if (item is WebFormStep)
                {
                    typeNode = parentNode.Nodes["WebForm"];

                    if (typeNode == null)
                    {
                        typeNode = new TreeNode("Web Forms")
                        {
                            Name = "WebForm"
                        };
                        rootNodes[item.WebsiteReference.Id].Nodes.Add(typeNode);
                    }

                    WebFormStep wfStep = (WebFormStep)item;
                    wfStep.JavaScript.StateChanged += JavaScript_StateChanged;

                    var node = new TreeNode(wfStep.Name)
                    {
                        Tag = wfStep.JavaScript
                    };
                    wfStep.JavaScript.Node = node;

                    if (wfStep.WebFormReference != null)
                    {
                        TreeNode webFormNode;

                        if (typeNode.Nodes.ContainsKey(wfStep.WebFormReference.Name))
                        {
                            webFormNode = typeNode.Nodes[wfStep.WebFormReference.Name];
                        }
                        else
                        {
                            webFormNode = new TreeNode(wfStep.WebFormReference.Name)
                            {
                                Name = wfStep.WebFormReference.Name
                            };

                            typeNode.Nodes.Add(webFormNode);
                        }

                        webFormNode.Nodes.Add(node);
                    }
                    else
                    {
                        typeNode.Nodes.Add(node);
                    }
                }
                else
                {
                    throw new Exception($"Unsupported portal item type: {item.GetType().Name}");
                }
            }

            foreach (var node in rootNodes.Values)
            {
                ApplyCounting(node, "WebPage");
                ApplyCounting(node, "EntityForm");
                ApplyCounting(node, "EntityList");
                ApplyCounting(node, "WebTemplate");
                ApplyCounting(node, "WebFile");
                ApplyCounting(node, "WebForm");

                tvCodeItems.Nodes.Add(node);
                node.Expand();
            }
        }
Exemple #21
0
 public void SetEntityForm(EntityForm EntityForm)
 {
     this.EntityForm = EntityForm;
 }
Exemple #22
0
        // 装载数据
        public override bool LoadData()
        {
            string strError = "";
            int    nRet     = 0;

            BiblioInfo info       = this.BiblioInfo;
            string     strRecPath = this.BiblioInfo.RecPath;

            if (string.IsNullOrEmpty(info.OldXml) == true)
            {
                lock (syncRoot)
                {
                    channel = Program.MainForm.GetChannel();
                }
                try
                {
                    // 显示 正在处理
                    this.HTML = GetWaitingHtml("正在获取 " + this.DbType + " 记录 " + strRecPath);
                    ShowData();

                    byte [] baTimestamp      = null;
                    string  strOutputRecPath = "";
                    string  strBiblio        = "";
                    string  strBiblioRecPath = "";
                    string  strXml           = "";

                    // 获得记录
                    channel.Timeout = new TimeSpan(0, 0, 5);
                    long lRet = 0;
                    if (this.DbType == "item")
                    {
                        lRet = channel.GetItemInfo(
                            this.Stop,
                            "@path:" + strRecPath,
                            "xml",
                            out strXml,
                            out strOutputRecPath,
                            out baTimestamp,
                            "",
                            out strBiblio,
                            out strBiblioRecPath,
                            out strError);
                    }
                    else if (this.DbType == "order")
                    {
                        lRet = channel.GetOrderInfo(
                            this.Stop,
                            "@path:" + strRecPath,
                            "xml",
                            out strXml,
                            out strOutputRecPath,
                            out baTimestamp,
                            "",
                            out strBiblio,
                            out strBiblioRecPath,
                            out strError);
                    }
                    else if (this.DbType == "issue")
                    {
                        lRet = channel.GetIssueInfo(
                            this.Stop,
                            "@path:" + strRecPath,
                            "xml",
                            out strXml,
                            out strOutputRecPath,
                            out baTimestamp,
                            "",
                            out strBiblio,
                            out strBiblioRecPath,
                            out strError);
                    }
                    else if (this.DbType == "comment")
                    {
                        lRet = channel.GetCommentInfo(
                            this.Stop,
                            "@path:" + strRecPath,
                            "xml",
                            out strXml,
                            out strOutputRecPath,
                            out baTimestamp,
                            "",
                            out strBiblio,
                            out strBiblioRecPath,
                            out strError);
                    }
                    else if (this.DbType == "patron")
                    {
                        string[] results = null;
                        // 获得读者记录
                        lRet = channel.GetReaderInfo(
                            this.Stop,
                            "@path:" + strRecPath,
                            "xml",
                            out results,
                            out strOutputRecPath,
                            out baTimestamp,
                            out strError);
                        if (lRet == 1)
                        {
                            if (results == null || results.Length == 0)
                            {
                                strError = "results error";
                                nRet     = -1;
                            }
                            else
                            {
                                strXml = results[0];
                            }
                        }
                    }
                    else
                    {
                        lRet     = -1;
                        strError = "无法识别的 DbType '" + this.DbType + "'";
                    }

                    if (lRet == 0)
                    {
                        nRet     = -1;
                        strError = "获取记录 " + strRecPath + " 时出错: " + strError;
                    }
                    else if (lRet == -1)
                    {
                        nRet     = -1;
                        strError = "获取记录 " + strRecPath + " 时出错: " + strError;
                    }
                    else
                    {
                        info.OldXml    = strXml;
                        info.Timestamp = baTimestamp;
                        info.RecPath   = strRecPath;
                    }
                }
                finally
                {
                    LibraryChannel temp_channel = channel;
                    lock (syncRoot)
                    {
                        channel = null;
                    }
                    Program.MainForm.ReturnChannel(temp_channel);
                }
            }

            string strXml1  = "";
            string strHtml2 = "";

            if (nRet == -1)
            {
                strHtml2 = HttpUtility.HtmlEncode(strError);
            }
            else
            {
                nRet = ItemSearchForm.GetXmlHtml(info,
                                                 out strXml1,
                                                 out strHtml2,
                                                 out strError);
                if (nRet == -1)
                {
                    throw new Exception(strError);
                }
            }

            this.HTML = "<html>" +
                        Program.MainForm.GetMarcHtmlHeadString(true) +
                        "<body>" +
                        strHtml2 +
                        EntityForm.GetTimestampHtml(info.Timestamp) +
                        "</body></html>";

            this.XML = strXml1;
            return(true);
        }
Exemple #23
0
        public override Panel ShowAddForm(object Object = null)
        {
            student EditStudent = (student)Object;
            bool    EditState   = EditStudent != null;

            ClearAllFields();
            UpdateList();
            Button BtnAdd = new Button()
            {
                Text = "Add"
            };

            BtnAdd.Click += (e, o) =>
            {
                if (ClassList.SelectedItem == null)
                {
                    ClassList.SelectedItem = ClassList.Items.IndexOf(0);
                }
                student Student = new student()
                {
                    id       = EditState ? InputID.Text : null,
                    name     = InputName.Text.Trim(),
                    email    = InputEmail.Text.Trim(),
                    address  = InputAddress.Text.Trim(),
                    class_id = ((ComboboxItem)ClassList.SelectedItem).Value.ToString(),
                    bod      = getBODString(),
                    issues   = null,
                    visits   = null,
                    AppUser  = null,
                    @class   = null
                };
                if (null != UserClient.AddStudent(Student, AppUser))
                {
                    MessageBox.Show("Success");
                    EntityForm.Navigate(0, 0);
                }
                else
                {
                    MessageBox.Show("Failed");
                }
            };
            InputID.Enabled = false;
            InputID.Text    = "GENERATED";

            if (EditState)
            {
                DateTime BOD = StringUtil.StringToDateTime(EditStudent.bod);
                InputID.Text           = EditStudent.id;
                InputName.Text         = EditStudent.name.Trim();
                InputEmail.Text        = EditStudent.email.Trim();
                InputAddress.Text      = EditStudent.address.Trim();
                ClassList.SelectedItem = EditStudent.class_id;
                CbxDay.SelectedValue   = BOD.Day;
                CbxMonth.SelectedValue = BOD.Month;
                CbxYear.SelectedValue  = BOD.Year;
            }

            Control[] Controls = new Control[]
            {
                new TitleLabel(20)
                {
                    Text = "Add Student"
                }, new BlankControl(),
                new Label()
                {
                    Text = "ID"
                }, InputID,
                new Label()
                {
                    Text = "Name"
                }, InputName,
                new Label()
                {
                    Text = "BOD"
                }, BODPanel,
                new Label()
                {
                    Text = "Email"
                }, InputEmail,
                new Label()
                {
                    Text = "Address"
                }, InputAddress,
                new Label()
                {
                    Text = "Class"
                }, ClassList,
                BtnAdd, null
            };

            return(ControlUtil.GeneratePanel(2, Controls, 5, 180, 30, Color.Aqua));
        }
Exemple #24
0
 public BaseEntityForm(EntityForm form, string color) : this()
 {
     this.form  = form;
     this.color = color;
 }
        private void RenderCrmEntityFormView(string entityName, string primaryFieldName, Entity serviceRequestType, Guid trueRecordId, FormViewMode formMode)
        {
            var serviceRequestDataSource = CreateDataSource("SeriveRequestDataSource", entityName, primaryFieldName, trueRecordId);

            Entity entityForm = null;

            entityForm = (serviceRequestType.GetAttributeValue <EntityReference>("adx_entityformid") != null)
                                ? XrmContext.CreateQuery("adx_entityform").FirstOrDefault(e => e.GetAttributeValue <Guid>("adx_entityformid") ==
                                                                                          serviceRequestType.GetAttributeValue <EntityReference>("adx_entityformid").Id) :
                         XrmContext.CreateQuery("adx_entityform").FirstOrDefault(ef => ef.GetAttributeValue <string>("adx_name")
                                                                                 == "Web Service Request Details" && ef.GetAttributeValue <string>("adx_entityname") == entityName);

            if (entityForm != null)
            {
                var formRecordSourceDefinition = new FormEntitySourceDefinition(entityName, primaryFieldName, trueRecordId);

                var entityFormControl = new EntityForm(entityForm.ToEntityReference(), formRecordSourceDefinition)
                {
                    ID                     = "CustomEntityFormControl",
                    FormCssClass           = "crmEntityFormView",
                    PreviousButtonCssClass = "btn btn-default",
                    NextButtonCssClass     = "btn btn-primary",
                    SubmitButtonCssClass   = "btn btn-primary",
                    ClientIDMode           = ClientIDMode.Static                                                         /*,
                                                                                                                          * EntityFormReference	= entityForm.ToEntityReference(),
                                                                                                                          * EntitySourceDefinition = formRecordSourceDefinition*/
                };

                var languageCodeSetting = ServiceContext.GetSiteSettingValueByName(Portal.Website, "Language Code");
                if (!string.IsNullOrWhiteSpace(languageCodeSetting))
                {
                    int languageCode;
                    if (int.TryParse(languageCodeSetting, out languageCode))
                    {
                        entityFormControl.LanguageCode = languageCode;
                    }
                }

                CrmEntityFormViewPanel.Controls.Add(entityFormControl);
            }
            else
            {
                var mappingFieldCollection = new MappingFieldMetadataCollection()
                {
                    FormattedLocationFieldName = serviceRequestType.GetAttributeValue <string>("adx_locationfieldname"),
                    LatitudeFieldName          = serviceRequestType.GetAttributeValue <string>("adx_latitudefieldname"),
                    LongitudeFieldName         = serviceRequestType.GetAttributeValue <string>("adx_longitudefieldname")
                };

                var serviceRequestFormView = new CrmEntityFormView()
                {
                    FormName               = "Web Details",
                    Mode                   = formMode,
                    EntityName             = entityName,
                    CssClass               = "crmEntityFormView",
                    SubmitButtonCssClass   = "btn btn-primary",
                    AutoGenerateSteps      = false,
                    ClientIDMode           = ClientIDMode.Static,
                    MappingFieldCollection = mappingFieldCollection
                };

                var languageCodeSetting = ServiceContext.GetSiteSettingValueByName(Portal.Website, "Language Code");
                if (!string.IsNullOrWhiteSpace(languageCodeSetting))
                {
                    int languageCode;
                    if (int.TryParse(languageCodeSetting, out languageCode))
                    {
                        serviceRequestFormView.LanguageCode         = languageCode;
                        serviceRequestFormView.ContextName          = languageCode.ToString(CultureInfo.InvariantCulture);
                        serviceRequestDataSource.CrmDataContextName = languageCode.ToString(CultureInfo.InvariantCulture);
                    }
                }

                CrmEntityFormViewPanel.Controls.Add(serviceRequestFormView);

                serviceRequestFormView.DataSourceID = serviceRequestDataSource.ID;
            }
        }
        public override Panel ShowAddForm(object Object = null)
        {
            book EditBook  = (book)Object;
            bool EditState = EditBook != null;

            ClearAllFields();
            UpdateList();
            Button BtnAdd = new Button()
            {
                Text = "Add"
            };

            BtnAdd.Click += (e, o) =>
            {
                book Book = new book()
                {
                    id           = EditState ? InputID.Text : null,
                    title        = InputTitle.Text.Trim(),
                    review       = InputReview.Text.Trim(),
                    page         = int.Parse(InputPage.Text.Trim()),
                    isbn         = InputISBN.Text.Trim(),
                    author_id    = ((ComboboxItem)AuthorList.SelectedItem).Value.ToString(),
                    publisher_id = ((ComboboxItem)PublisherList.SelectedItem).Value.ToString(),
                    category_id  = ((ComboboxItem)CategoryList.SelectedItem).Value.ToString()
                    ,
                    book_record = null
                };
                if (null != UserClient.AddBook(Book, AppUser))
                {
                    MessageBox.Show("Success");
                    EntityForm.Navigate(0, 0);
                }
                else
                {
                    MessageBox.Show("Failed");
                }
            };
            InputID.Enabled = false;
            InputID.Text    = "GENERATED";
            if (EditState)
            {
                InputID.Text                = EditBook.id;
                InputTitle.Text             = EditBook.title;
                InputReview.Text            = EditBook.review;
                InputISBN.Text              = EditBook.isbn;
                InputPage.Text              = EditBook.page.ToString();
                AuthorList.SelectedValue    = EditBook.author_id;
                PublisherList.SelectedValue = EditBook.publisher_id;
                CategoryList.SelectedValue  = EditBook.category_id;
            }

            Control[] Controls = new Control[]
            {
                new TitleLabel(20)
                {
                    Text = "Add Book"
                }, new BlankControl(),
                new Label()
                {
                    Text = "ID"
                }, InputID,
                new Label()
                {
                    Text = "Title"
                }, InputTitle,
                new Label()
                {
                    Text = "Author"
                }, AuthorList,
                new Label()
                {
                    Text = "Publisher"
                }, PublisherList,
                new Label()
                {
                    Text = "Category"
                }, CategoryList,
                new Label()
                {
                    Text = "Page"
                }, InputPage,
                new Label()
                {
                    Text = "ISBN"
                }, InputISBN,
                new Label()
                {
                    Text = "Review"
                }, InputReview,
                BtnAdd, null
            };

            return(ControlUtil.GeneratePanel(2, Controls, 5, 180, 30, Color.Aqua));
        }