예제 #1
0
        //send mail
        //public ActionResult SendMail(SendMail model)
        //{
        //    var mailconfig = sc.getOneObject("mailconfig", Organize.ID);
        //    if (mailconfig == null)
        //        return Json(new { success = false, msg = "You should config mail sender first." }, JsonRequestBehavior.AllowGet);
        //    var config = mailconfig.Attrs.ToDictionary(m => m.AttrName, m => m.AttrValue);
        //    try
        //    {
        //        var template = sc.findObject("mailtemplate", model.TemplateID, Organize.ID);
        //        if (template == null)
        //            return Json(new { success = false, msg = "Template not found" }, JsonRequestBehavior.AllowGet);
        //        var SmtpServer = new SmtpClient(config["host"]);
        //        SmtpServer.Port = int.Parse(config["port"]);
        //        SmtpServer.Credentials = new System.Net.NetworkCredential(config["user"], config["password"]);
        //        SmtpServer.EnableSsl = true;
        //        List<Receiver> listerror = new List<Receiver>();
        //        List<gModels.gObjectAttr> listAttr = new List<gObjectAttr>();
        //        string recevers = "";
        //        foreach (var receiver in model.Receivers)
        //        {
        //            try
        //            {
        //                var email = new GuMail();
        //                email.mSmtp = SmtpServer;
        //                email.From = config["user"];
        //                //get email template
        //                var templateconfig = template.Attrs.ToDictionary(m => m.AttrName, m => m.AttrValue);
        //                email.Title = template.Title;
        //                email.ContentText = templateconfig["shortdescription"];
        //                email.ContentHtml = templateconfig["mailcontent"];
        //                email.To = receiver.text;
        //                email.Send();
        //                if (recevers != "") recevers += "," + receiver.text;
        //                else recevers += receiver.text;
        //            }
        //            catch
        //            {
        //                listerror.Add(receiver);
        //            }
        //        }
        //        listAttr.Add(new gModels.gObjectAttr() { ID = 9, AttrValue = recevers, gObjectGroupID = 3, Status = 1, CreateDate = DateTime.Now, AttrType = 17 });
        //        listAttr.Add(new gModels.gObjectAttr() { ID = 11, AttrValue = JsonConvert.SerializeObject(template), gObjectGroupID = 3, Status = 1, CreateDate = DateTime.Now, AttrType = 4 });
        //        //hh
        //        sc.UpdateOneModel(new gObject()
        //        {
        //            Title = template.Title,
        //            CreateDate = DateTime.Now,
        //            Status = 1,
        //            gGroupID = 3,
        //            Slug = template.Slug,
        //            Attrs = listAttr
        //        }, Organize.ID);
        //        return Json(new { success = true, error = listerror }, JsonRequestBehavior.AllowGet);
        //    }
        //    catch (Exception ex)
        //    {
        //        return Json(new { success = false, mgs = ex.Message }, JsonRequestBehavior.AllowGet);
        //    }
        //}
        //get object home
        public ActionResult GetPanelObjects(string objects)
        {
            string[] spobjects = objects.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            List<gModels.gPanelObject> List = new List<gPanelObject>();

            foreach (var objname in spobjects)
            {
                gModels.gPanelObject panel = new gPanelObject();
                panel.Categorys = sc.ListObjectWithCondition(objname, "isnull(ParentID,0)=0 and isnull(gShowHome,0)=1  and isnull(gEnabled,0)=1 ", 0, Organize.ID);
                panel.gObjectName = objname;
                if (panel.Categorys.Count > 0)
                {
                    panel.gObjectDisplayName = panel.Categorys[0].gObjectDisplayName;
                }
                else
                {
                    panel.gObjectDisplayName = objname;
                }

                panel.ListBestBuy = sc.ListObjectWithCondition(objname, "isnull(ParentID,0)<>0 and gBestBuy=1 and isnull(gEnabled,0)=1", 0, Organize.ID);
                panel.ListShowHome = sc.ListObjectWithCondition(objname, "isnull(ParentID,0)<>0 and gShowHome=1 and isnull(gEnabled,0)=1", 0, Organize.ID);
                List.Add(panel);
            }
            return Json(new { success = true, data = List }, JsonRequestBehavior.AllowGet);
        }
예제 #2
0
        public ActionResult GetViewObject(string objectname, int childget = 12)
        {
            gModels.gPanelObject panel = new gPanelObject();
            panel.Categorys = sc.parentListHome(objectname, 0, Organize.ID);
            panel.gObjectName = objectname;
            if (panel.Categorys.Count > 0)
            {
                panel.gObjectDisplayName = panel.Categorys[0].gObjectDisplayName;
            }
            else
            {
                panel.gObjectDisplayName = objectname;
            }
            foreach (var cat in panel.Categorys)
            {
                cat.Childrens = sc.ListObjectWithCondition(objectname, "ParentID=" + cat.ID + " and isnull(gEnabled,0)=1 ", childget, Organize.ID);
            }

            panel.ListBestBuy = sc.ListObjectWithCondition(objectname, "ParentID is not null and gBestBuy=1 and isnull(gEnabled,0)=1 ", 0, Organize.ID);

            return Json(new { success = true, data = panel }, JsonRequestBehavior.AllowGet);
        }
예제 #3
0
        //get object for links
        public ActionResult GetLinkPanelObjectsHome(string objects, string childorderby, string parentorderby)
        {
            string[] spobjects = objects.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            List<gModels.gPanelObject> List = new List<gPanelObject>();
            foreach (var objname in spobjects)
            {
                gModels.gPanelObject panel = new gPanelObject();
                panel.Categorys = sc.ListObjectWithChildHome(objname, Organize.ID, childorderby, parentorderby);
                panel.gObjectName = objname;
                if (panel.Categorys.Count > 0)
                {
                    panel.gObjectDisplayName = panel.Categorys[0].gObjectDisplayName;
                }
                else
                {
                    panel.gObjectDisplayName = objname;
                }

                List.Add(panel);
            }
            return Json(new { success = true, data = List }, JsonRequestBehavior.AllowGet);
        }