コード例 #1
0
 protected void CheckLock(ActiveRecord record)
 {
     if (record == null)
     {
         return;
     }
     lockobj.InitLocking(Security.LoggedInUserID);
     if (!lockobj.LockTable(record.GetTableName(), (record[record.GetPrimaryKeyName()] + "").ToIntOrDie(), record.GetName()))
     {
         Web.ErrorMessage = lockobj.LockMessage;
     }
 }
コード例 #2
0
ファイル: SavvyHtmlHelpers.cs プロジェクト: cmcd74/SavvyCMS
        public static MvcHtmlString ChildListLink(this HtmlHelper htmlHelper, ActiveRecord listItem, string childTableName, string linkText = null, string foreignKeyName = null)
        {
            if (linkText == null)
            {
                linkText = "Items";
            }
            if (foreignKeyName == null)
            {
                foreignKeyName = listItem.GetPrimaryKeyName();                                      // fk is often to a pk the same name
            }
            string url = Web.AdminRoot + childTableName + "Admin";

            url += "/?bread=" + (Breadcrumbs.Current.CurrentLevel + 1) + "&" + foreignKeyName + "=" + listItem.ID_Field.ToString().UrlEncode();
            // <span class="badge">42</span>
            string html = "<a href=\"" + url + "\">" + linkText.HtmlEncode() + "</a>";

            return(MvcHtmlString.Create(html));
        }
コード例 #3
0
        public static void CheckAttachmentsForDocOrPDFText(ActiveRecord record)
        {
            //walk the field list for this record looking for attachments
            foreach (var fieldName in record.GetFieldNames())
            {
                if (fieldName.Contains("Attachment") && fieldName.DoesntContain("RawText"))
                {
                    //if (record.Fields.Attachment.IsDirty) {
                    if (ActiveFieldBase.IsDirtyObj(record[fieldName].ValueObject, record[fieldName].OriginalValueObject))
                    {
                        if (record[fieldName].ToString().Contains(".doc") || record[fieldName].ToString().EndsWith(".pdf") || record[fieldName].ToString().EndsWith(".rtf"))
                        {
                            if (!record.FieldExists(fieldName + "RawText"))
                            {
                                (new Sql("ALTER TABLE ", record.GetTableName().SqlizeName(), " ADD [" + fieldName + "RawText] nvarchar (MAX);")).Execute();
                            }
                            string output = "";
                            if (record[fieldName].ToString().ToLower().EndsWith(".doc"))
                            {
                                OfficeFileReader.OfficeFileReader objOFR = new OfficeFileReader.OfficeFileReader();
                                if (objOFR.GetText(Web.MapPath(Web.Attachments) + record[fieldName].ToString(), ref output) > 0)
                                {
                                    //ok
                                }
                            }
                            else if (record[fieldName].ToString().ToLower().EndsWith(".docx"))
                            {
                                BewebCore.ThirdParty.ReadWordDocText.DocxToText objOFR = new DocxToText(Web.MapPath(Web.Attachments) + record[fieldName].ToString());
                                if ((output = objOFR.ExtractText()).Length > 0)
                                {
                                    //ok
                                }
                            }
                            else if (record[fieldName].ToString().Contains(".pdf"))
                            {
                                PdfToText.PDFParser pdf = new PDFParser();
                                if (pdf.ExtractText(Web.MapPath(Web.Attachments) + record[fieldName].ToString(), ref output))
                                {
                                    //ok
                                }
                            }
                            else if (record[fieldName].ToString().Contains(".rtf"))
                            {
#if RTFProcessingAvailable
                                //Create the RTF tree object
                                RtfTree tree = new RtfTree();

                                //Load and parse RTF document
                                tree.LoadRtfFile(Web.MapPath(Web.Attachments) + record[fieldName].ToString());
                                output = tree.Text;
#else
                                throw new Exception("rtf library not included");
#endif
                            }
                            if (output.Trim() != "")
                            {
                                (new Sql("update ", record.GetTableName().SqlizeName(), "set " + fieldName + "RawText=", output.SqlizeText(), " where ",
                                         record.GetPrimaryKeyName().SqlizeName(), "=", record.ID_Field.Sqlize(), "")).Execute();
                            }
                        }
                        else
                        {
                            //no doc any more
                            if (record.FieldExists(fieldName + "RawText"))
                            {
                                (new Sql("update ", record.GetTableName().SqlizeName(), "set " + fieldName + "RawText=null where ",
                                         record.GetPrimaryKeyName().SqlizeName(), "=", record.ID_Field.Sqlize(), "")).Execute();
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: SavvyHtmlHelpers.cs プロジェクト: cmcd74/SavvyCMS
        public static MvcHtmlString DraggableSortPosition(this HtmlHelper htmlHelper, ActiveRecord listItem, int?sortPositionCurrentValue, object sortGroup = null, string action = "SaveSortOrder")
        {
            Beweb.Util.IncludeJavascriptFile("~/js/redips_drag/redips-drag.min.js");
            string url = new UrlHelper(htmlHelper.ViewContext.RequestContext).Action(action);

            url += "?t=" + Crypto.Encrypt(listItem.GetTableName()) + "&p=" + Crypto.Encrypt(listItem.GetPrimaryKeyName());
            Beweb.Util.IncludeJavascript("$(function() { svyInitSortPositionTableDrag(\"" + url + "\"); });");

            string html = "<td class=\"rowhandler\"><div class=\"drag row\" title=\"Drag to change sort position\"><i class=\"icon-align-justify\"></i> <span class=\"svyRowSort\" data-pkid=" + listItem.ID_Field.ToString() + " data-sortgroup=" + sortGroup + ">" + sortPositionCurrentValue + "</span><input type=\"hidden\" name=\"SortPosition" + Forms.CurrentRowSuffix + "\" value=\"" + sortPositionCurrentValue + "\"></div></td>";


            if (Web.Request["Search"].IsNotBlank() || (Web.Request["ColSortField"].IsNotBlank() && Web.Request["ColSortField"] != "SortPosition"))               // hide sortable if in middle of a search filter
            {
                html = "<td class=\"rowhandler\"><div class=\"row\">" + sortPositionCurrentValue + "</div></td>";
            }
            return(MvcHtmlString.Create(html));
        }