コード例 #1
0
        private DisplayReportItem GetDisplayItem(int id, out string errormessage)
        {
            ReportItemBase reportBase = new DBContent().GetReport(id, out errormessage);
            if (!String.IsNullOrWhiteSpace(errormessage))
            {
                return null;
            }

               Dictionary<string, object> formValues = (this.Request.Form as Nancy.DynamicDictionary).ToDictionary();

            return new DisplayReportItem(reportBase, formValues);
        }
コード例 #2
0
        protected override ApplyResult ProcessApplyItem(ref object obj, out string errormessage, out string successmessage, out bool edited)
        {
            errormessage = "";
            successmessage = "";
            edited = false;
            string action = this.Request.Form.action.Value.ToLower();
            int objectID = -1;
            if (this.Request.Form.objectID != null)
            {
                objectID = int.Parse(this.Request.Form.objectID.Value.ToString());
            }

            string html = this.Request.Form.HTML.Value;

            FormItem item = new FormItem(objectID,
                                         this.Request.Form.Name.Value,
                                         html);
            obj = item;

            switch (action)
            {
                case BaseWebModule.PostSave:

                    List<SWBaseTag> tags = SWBaseTag.GetTags(html, SWBaseTag.BaseTagTypes.Form);
                    foreach (SWBaseTag t1 in tags)
                    {
                        foreach (SWBaseTag t2 in tags)
                        {
                            if (!t1.Equals(t2) &&
                                t1.Name.Equals(t2.Name))
                            {
                                errormessage = String.Format("There are one or more tags with the same name {0}.", t1.Name);
                                return ApplyResult.Message;
                            }
                        }
                    }

                    bool result = false;
                    result = new DBContent().SaveForm(item, out errormessage);
                    edited = item.ID > 0;

                    if (result)
                    {
                        return ApplyResult.Save;
                    }
                    break;
                case BaseWebModule.PostCancel:
                    return ApplyResult.Cancel;
            }
            return ApplyResult.Message;
        }
コード例 #3
0
        private string ProcessSelectTag(SWSelectTag tag, DBContent.TagValueItemTypes htmlType, out string errormessage)
        {
            errormessage = "";

            switch (htmlType)
            {
                case DBContent.TagValueItemTypes.Template:
                    return ProcessSelectTag_Template(tag, out errormessage);
                case DBContent.TagValueItemTypes.Form:
                    return ProcessSelectTag_Form(tag, out errormessage);
            }
            return "";
        }
コード例 #4
0
 private string ProcessInputTextTag(SWInputTextTag tag, DBContent.TagValueItemTypes htmlType, out string errormessage)
 {
     errormessage = "";
     if (tag == null) return "";
     switch (htmlType)
     {
         case DBContent.TagValueItemTypes.Form:
             string html = String.Format("<input type=\"text\" class=\"form-control\" id = \"i{0}\" name=\"{0}\" />", tag.Name);
             if (this.PhysicalFormValues.ContainsKey(tag.Name))
             {
                 html += "<script>$(document).ready(function (){";
                 html += String.Format("$('#i{0}').val('{1}');", tag.Name, this.PhysicalFormValues[tag.Name]);
                 html += "});</script>";
             }
             return html;
         case DBContent.TagValueItemTypes.Template:
             if (this.PhysicalFormValues.ContainsKey(tag.Name))
             {
                 object value = this.PhysicalFormValues[tag.Name];
                 if (value != null)
                 {
                     return WebUtility.HtmlEncode(value.ToString());
                 }
             }
             break;
     }
     return "";
 }
コード例 #5
0
        private string ProcessInputDateTimeTag(SWBaseInputDateTimeTag tag, DBContent.TagValueItemTypes htmlType, out string errormessage)
        {
            errormessage = "";
            if (tag == null) return "";
            switch (htmlType)
            {
                case DBContent.TagValueItemTypes.Form:
                    string html = "";

                    string typealias = "";
                    switch (tag.TagType)
                    {
                        case SWInputDateTag.Type:
                            typealias = "date";
                            break;
                        case SWInputTimeTag.Type:
                            typealias = "time";
                            break;
                    }

                    html += String.Format("<input type=\"{0}\" class=\"form-control\" id = \"i{1}\" name=\"{1}\" />", typealias, tag.Name);
                    if (this.PhysicalFormValues.ContainsKey(tag.Name))
                    {
                        html += "<script>$(document).ready(function (){";
                        html += String.Format("$('#i{0}').val('{1}');", tag.Name, this.PhysicalFormValues[tag.Name]);
                        html += "});</script>";
                    }
                    else
                    {
                        html += @"<script>$(document).ready(function ()
                              {
                                var now = new Date();
                                var day = ('0' + now.getDate()).slice(-2);
                                var month = ('0' + (now.getMonth() + 1)).slice(-2);
                                var today = now.getFullYear()+'-'+(month)+'-'+(day);
                                var todaytime = now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();
                                ";

                        switch (tag.TagType)
                        {
                            case SWInputDateTag.Type:
                                html += String.Format("$('#i{0}').val(today);", tag.Name);
                                break;
                            case SWInputTimeTag.Type:
                                html += String.Format("$('#i{0}').val(todaytime);", tag.Name);
                                break;
                        }

                        html += "});</script>";
                    }
                    return html;
                case DBContent.TagValueItemTypes.Template:
                    if (this.PhysicalFormValues.ContainsKey(tag.Name))
                    {
                        object value = this.PhysicalFormValues[tag.Name];
                        if (value != null)
                        {
                            return WebUtility.HtmlEncode(value.ToString());
                        }
                    }
                    break;
            }
            return "";
        }
コード例 #6
0
 public MotherboardRepository(DBContent dbContent)
 {
     this.dbContent = dbContent;
 }
コード例 #7
0
 protected override object ProcessEditItem(int id)
 {
     ConnectionItem item = new DBContent().GetConnection(id);
     if (item != null)
     {
         item.RefreshDatabases();
     }
     return item;
 }
コード例 #8
0
        private void CreateHTML(out string errormessage,
            ref string html,
            DBContent.TagValueItemTypes htmlType)
        {
            errormessage = "";
            if (String.IsNullOrWhiteSpace(html)) return;

            int startIndex = -1;
            int endIndex = -1;

            while ((startIndex = html.IndexOf(SWBaseTag.TagStart.ToLower(), endIndex + 1, StringComparison.CurrentCultureIgnoreCase)) >= 0)
            {
                endIndex = html.IndexOf(SWBaseTag.TagEnd.ToLower(), startIndex);
                int tempStart = html.IndexOf(SWBaseTag.TagStart.ToLower());
                if (tempStart > endIndex) continue;

                string xmlTag = html.Substring(startIndex, endIndex - startIndex + 1);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xmlTag.ToLower());
                XmlNode newNode = doc.DocumentElement;

                SWBaseTag tag = null;
                XmlAttribute typeAttr = newNode.Attributes[SWBaseTag.TypeAttribute];
                if (typeAttr != null)
                {
                    tag = SWBaseTag.GetTag(typeAttr.Value);
                }

                if (tag == null) continue;

                XmlAttribute nameAttr = newNode.Attributes[SWBaseTag.NameAttribute];
                if (nameAttr != null)
                {
                    tag.Name = nameAttr.Value;
                }

                string newHTML = this.ProcessTag(tag, htmlType, out errormessage);
                if (newHTML == null)
                {
                    newHTML = "";
                }
                int s = newHTML.Length;
                if (!String.IsNullOrWhiteSpace(errormessage))
                {
                    html = null;
                    return;
                }

                html = html.Substring(0, startIndex) +
                            newHTML +
                            html.Substring(endIndex + 1, html.Length - endIndex - 1);
                int takeaway = endIndex - startIndex + 1;
                startIndex += newHTML.Length - takeaway;
                endIndex += newHTML.Length - takeaway;
            }
        }
コード例 #9
0
 public PostRepository(DBContent context)
 {
     this.context = context;
 }
コード例 #10
0
 public CategoryGPURepository(DBContent dbContent)
 {
     this.dbContent = dbContent;
 }
コード例 #11
0
 public VideoCardRepository(DBContent dbContent)
 {
     this.dbContent = dbContent;
 }
コード例 #12
0
ファイル: PhoneRepository.cs プロジェクト: f1ngerl1ng/ASP.NET
 public PhoneRepository(DBContent dbContent)
 {
     this.dbContent = dbContent;
 }
コード例 #13
0
 public ProcesorRepository(DBContent dbContent)
 {
     this.dbContent = dbContent;
 }
コード例 #14
0
 public override bool TryGet(string _mainClass, out DBContent _outObject, string _key)
 {
     _outObject = Get(_mainClass, _key);
     return(_outObject != null);
 }
コード例 #15
0
 public ZakazRepositoriy(DBContent _dBContent, Korzina _korzina)
 {
     this._dBContent = _dBContent;
     this._korzina   = _korzina;
 }
コード例 #16
0
        private string ProcessTag(SWBaseTag tag, DBContent.TagValueItemTypes htmlType, out string errormessage)
        {
            errormessage = "";
            if (tag == null)
            {
                return "";
            }

            switch (tag.TagType)
            {
                case SWInputTextTag.Type:
                    return this.ProcessInputTextTag(tag as SWInputTextTag, htmlType, out errormessage);
                case SWInputDateTag.Type:
                case SWInputTimeTag.Type:
                    return this.ProcessInputDateTimeTag(tag as SWBaseInputDateTimeTag, htmlType, out errormessage);
                case SWDateTag.Type:
                    return DateTime.Now.ToString();
                case SWVarTag.Type:
                    return this.ProcessVarTag(tag as SWVarTag, htmlType, out errormessage);
                case SWQueryTag.Type:
                    return this.ProcessQueryTag(tag as SWQueryTag, out errormessage);
                case SWSelectTag.Type:
                     return this.ProcessSelectTag(tag as SWSelectTag, htmlType, out errormessage);

             /*   case SWInputDateTag.Type:
                    switch (htmlType)
                    {
                        case DBContent.TagValueItemTypes.Form:
                            return this.ProcessInputDateTag(foundTag as SWInputDateTag, out errormessage);
                        case DBContent.TagValueItemTypes.Template:
                            return foundTag.Value;
                    }
                    break;*/
            }

            return "";
        }
コード例 #17
0
        private string ProcessVarTag(SWVarTag tag, DBContent.TagValueItemTypes htmlType, out string errormessage)
        {
            errormessage = "";
            if (tag == null) return "";

            ReadOnlyCollection<SWBaseTag> lst = null;
            switch (htmlType)
            {
                case DBContent.TagValueItemTypes.Form:
                    lst = this.ReportItem.FormTags;
                    break;
                case DBContent.TagValueItemTypes.Template:
                    lst = this.ReportItem.TemplateTags;
                    break;
            }

            tag = (from t in lst
                   where tag.Name.ToLower().Equals(t.Name.ToLower()) &&
                   tag.TagType.Equals(t.TagType)
                   select t as SWVarTag).FirstOrDefault();

            if (tag == null) return "";

            return tag.Value;
        }
コード例 #18
0
 public CPURepository(DBContent dbContent)
 {
     this.dbContent = dbContent;
 }
コード例 #19
0
        protected override object ProcessEditItem(int id)
        {
            this.Context.ViewBag.TemplateConst = ReportModule.Template;
            this.Context.ViewBag.FormConst = ReportModule.Form;

            string errormessage = "";
            ReportItemBase item = new DBContent().GetReport(id, out errormessage);
            if (item == null)
            {
                return null;
            }
            else
            {
                return new CreateReportItem(item);
            }
        }
コード例 #20
0
        protected override ApplyResult ProcessApplyItem(ref object obj, out string errormessage, out string successmessage, out bool edited)
        {
            string action = "";
            if (this.Request.Form.action != null)
            {
                action = this.Request.Form.action.Value.ToLower();
            }
            errormessage = "";
            successmessage = "";
            edited = false;
            switch (action)
            {
                case "cancel":
                    return ApplyResult.Cancel;
            }

            this.Context.ViewBag.TemplateConst = ReportModule.Template;
            this.Context.ViewBag.FormConst = ReportModule.Form;

            int id = -1;
            if (this.Request.Form.objectID != null)
            {
                int.TryParse(this.Request.Form.objectID.Value.ToString(), out id);
            }

            string name = this.Request.Form.Name.Value;
            string group = this.Request.Form.GroupName.Value;

            ConnectionItem connection = null;
            if (this.Request.Form.Connection != null)
            {
                connection = new DBContent().GetConnection(int.Parse(this.Request.Form.Connection.Value));
            }

            FormItem form = null;
            int formID;
            if (int.TryParse(this.Request.Form.Form, out formID))
            {
                form = new DBContent().GetForm(formID);
            }

            TemplateItem template = null;
            int templateID = -1;
            if (int.TryParse(this.Request.Form.Template, out templateID))
            {
                template = new DBContent().GetTemplate(templateID);
            }

            obj = new CreateReportItem(new ReportItemBase(id,
                                       name,
                                       group,
                                       connection,
                                       form,
                                       template));

            foreach (KeyValuePair<string, object> kvp in (this.Request.Form as Nancy.DynamicDictionary).ToDictionary())
            {
                string[] split = kvp.Key.Split('.');
                if (split.Count() <= 1) continue;

                SWBaseTag tag = null;
                switch (split[0])
                {
                    case ReportModule.Form:
                        tag = (obj as CreateReportItem).ReportItem.FormTags.Where(x => x.Name.Equals(split[1])).FirstOrDefault();
                        if (tag != null)
                        {
                            tag.Value = kvp.Value.ToString();
                        }
                        break;
                    case ReportModule.Template:
                        tag = (obj as CreateReportItem).ReportItem.TemplateTags.Where(x => x.Name.Equals(split[1])).FirstOrDefault();
                        if (tag != null)
                        {
                            tag.Value = kvp.Value.ToString();
                        }
                        break;
                }
            }

            switch (action)
            {
                case "save":
                    bool result = new DBContent().SaveReport((obj as CreateReportItem).ReportItem, out errormessage);
                    if (result)
                    {
                        edited = (obj as CreateReportItem).ID > 0;
                        return ApplyResult.Save;
                    }
                    else
                    {
                        return ApplyResult.Message;
                    }
                default:
                    return ApplyResult.Message;
            }
        }
コード例 #21
0
        protected override ApplyResult ProcessApplyItem(ref object obj, out string errorMessage, out string successMessage, out bool edited)
        {
            errorMessage = "";
            successMessage = "";
            edited = false;
            string action = this.Request.Form.action.Value.ToLower();
            int objectID = -1;
            if (this.Request.Form.objectID != null)
            {
                objectID = int.Parse(this.Request.Form.objectID.Value.ToString());
            }

            string defaultDatabase = "";
            if (this.Request.Form.DefaultDatabase != null)
            {
                defaultDatabase = this.Request.Form.DefaultDatabase.Value;
            }

            int port = 0;
            bool portError = false;
            if (this.Request.Form.ConnPort != null)
            {
                if (!int.TryParse(this.Request.Form.ConnPort.Value, out port))
                {
                    portError = true;
                }
            }
            ConnectionItem.ConnectionTypes type =
                    this.Request.Form.ConnectionTypes.Value == "mysql" ? ConnectionItem.ConnectionTypes.MySQL : ConnectionItem.ConnectionTypes.MSSQL;

            ConnectionItem item = new ConnectionItem(objectID,
                                                    this.Request.Form.Name.Value,
                                                    this.Request.Form.Host.Value,
                                                    port,
                                                    this.Request.Form.Username.Value,
                                                    this.Request.Form.Password.Value,
                                                    type,
                                                    defaultDatabase);
            obj = item;

            bool showRefreshMessage = false;
            switch (action)
            {
                case BaseWebModule.PostSave:
                    bool result = false;
                    if (!portError)
                    {
                        result = new DBContent().SaveConnection(item, out errorMessage);
                        edited = item.ID > 0;
                    }
                    else
                    {
                        errorMessage = "Invalid Port.";
                    }

                    if (result)
                    {
                        return ApplyResult.Save;
                    }
                    break;
                case ConnectionModule.PostRefresh:
                    showRefreshMessage = true;
                    break;
                case BaseWebModule.PostCancel:
                    return ApplyResult.Cancel;
                case ConnectionModule.PostTest:
                    if (ConnectionItem.TestConnection(item, out errorMessage))
                    {
                        successMessage = "Successfully connected to the database.";
                    }
                    break;
            }

            string message;
            if(item.RefreshDatabases(out message))
            {
                if (showRefreshMessage)
                {
                    successMessage = "Successfully refreshed.";
                }
            }
            else
            {
                if (showRefreshMessage)
                {
                    errorMessage = message;
                }
            }
            return ApplyResult.Message;
        }
コード例 #22
0
 public ShopCart(DBContent dBContent)
 {
     _dBContent = dBContent;
 }