public static SimpleJson GetWHInfo(ISession session, string area, string section) { if (string.IsNullOrEmpty(area) || area.Trim().Length <= 0) { return(new SimpleJson().HandleError("您没有选择库位")); } string a = area.Trim().ToUpper(); string sec = string.IsNullOrEmpty(section) ? "" : section.Trim().ToUpper(); SimpleJson json = new SimpleJson().Add("area", area).Add("section", sec); if (sec.Length <= 0) { //加载库位信息 WHArea whArea = WHArea.Retrieve(session, a); if (whArea == null) { return(json.HandleError("库位" + a + "不存在")); } json.Add("capacity", Cast.Int(whArea.AreaCapacity)); int stoQty = Cast.Int(session.CreateObjectQuery(@"select sum(StockQty) from StockDetail where AreaCode=?area group by AreaCode") .Attach(typeof(StockDetail)) .SetValue("?area", a, "AreaCode") .Scalar()); json.Add("stored", stoQty); } else { //加载货架信息 WHSection whSection = WHSection.Retrieve(session, a, sec); if (whSection == null) { return(json.HandleError("库位" + a + "中不存在货架号" + sec)); } json.Add("capacity", Cast.Int(whSection.SectionCapacity)); int stoQty = Cast.Int(session.CreateObjectQuery(@" select sum(StockQty) from StockDetail where AreaCode=?area and SectionCode=?section group by AreaCode") .Attach(typeof(StockDetail)) .SetValue("?area", a, "AreaCode") .SetValue("?section", sec, "SectionCode") .Scalar()); json.Add("stored", stoQty); } return(json); }
public void ProcessRequest(HttpContext context) { if (!Magic.Security.SecuritySession.Authenticated()) { context.Response.Write((new SimpleJson().HandleError("您还没有登陆或者登陆已经过期,请登陆系统!")).ToJsonString("yyyy-MM-dd HH:mm")); return; } string type = WebUtil.Param("type").Trim(); if (type.ToLower() == "1002") //execute the ascx control and return the response html { try { context.Server.Execute("AjaxControlsHandler.aspx", context.Response.Output, true); return; } catch (Exception error) { logger.Error("ExecuteControl", error); context.Response.Write(error.Message); return; } } if (type.ToLower() == "1001") { try { string result = MagicAjax.InvokeAjaxCall2String(); context.Response.Write(result); return; } catch (Exception error) { context.Response.Write(error.Message); return; } } //return json object SimpleJson json = new SimpleJson(); try { SimpleJson j = MagicAjax.InvokeAjaxCall2Json(); if (j != null) { json = j; } } catch (Exception error) { json.HandleError(error.Message); } context.Response.Write(json.ToJsonString("yyyy-MM-dd HH:mm")); }
public static SimpleJson GetWHInfo(ISession session, string area, string section) { if (string.IsNullOrEmpty(area) || area.Trim().Length <= 0) return new SimpleJson().HandleError("��û��ѡ���λ"); string a = area.Trim().ToUpper(); string sec = string.IsNullOrEmpty(section) ? "" : section.Trim().ToUpper(); SimpleJson json = new SimpleJson().Add("area", area).Add("section", sec); if (sec.Length <= 0) { //���ؿ�λ��Ϣ WHArea whArea = WHArea.Retrieve(session, a); if (whArea == null) return json.HandleError("��λ" + a + "������"); json.Add("capacity", Cast.Int(whArea.AreaCapacity)); int stoQty = Cast.Int(session.CreateObjectQuery(@"select sum(StockQty) from StockDetail where AreaCode=?area group by AreaCode") .Attach(typeof(StockDetail)) .SetValue("?area", a, "AreaCode") .Scalar()); json.Add("stored", stoQty); } else { //���ػ�����Ϣ WHSection whSection = WHSection.Retrieve(session, a, sec); if (whSection == null) return json.HandleError("��λ" + a + "�в����ڻ��ܺ�" + sec); json.Add("capacity", Cast.Int(whSection.SectionCapacity)); int stoQty = Cast.Int(session.CreateObjectQuery(@" select sum(StockQty) from StockDetail where AreaCode=?area and SectionCode=?section group by AreaCode") .Attach(typeof(StockDetail)) .SetValue("?area", a, "AreaCode") .SetValue("?section", sec, "SectionCode") .Scalar()); json.Add("stored", stoQty); } return json; }
public void ProcessRequest(HttpContext context) { if (!Magic.Security.SecuritySession.Authenticated()) { context.Response.Write((new SimpleJson().HandleError("您还没有登陆或者登陆已经过期,请登陆系统!")).ToJsonString("yyyy-MM-dd HH:mm")); return; } string type = WebUtil.Param("type").Trim(); if (type.ToLower() == "1002") //execute the ascx control and return the response html try { context.Server.Execute("AjaxControlsHandler.aspx",context.Response.Output, true); return; } catch (Exception error) { logger.Error("ExecuteControl", error); context.Response.Write(error.Message); return; } if (type.ToLower() == "1001") { try { string result = MagicAjax.InvokeAjaxCall2String(); context.Response.Write(result); return; } catch (Exception error) { context.Response.Write(error.Message); return; } } //return json object SimpleJson json = new SimpleJson(); try { SimpleJson j = MagicAjax.InvokeAjaxCall2Json(); if (j != null) json = j; } catch (Exception error) { json.HandleError(error.Message); } context.Response.Write(json.ToJsonString("yyyy-MM-dd HH:mm")); }
public static SimpleJson GetOrgJSON(ISession session, Org org) { SimpleJson json = new SimpleJson(); if (org == null) { json.HandleError("Org is null"); return(json); } json.Add("id", org.OrgId) .Add("parent", org.ParentId) .Add("root", org.IsRoot) .Add("virtual", org.IsVirtual) .Add("seq", org.OrgSeq) .Add("code", org.OrgCode) .Add("name", org.OrgName) .Add("remark", org.Description) .Add("desc", org); if (org.CreateBy > 0) { User createBy = User.Retrieve(session, org.CreateBy); if (createBy != null) { json.Add("createBy", string.IsNullOrEmpty(createBy.FullName) ? createBy.UserName : createBy.FullName); } else { Log.Warn <Org>("User {0} (CreateBy) not found when loading org {1}:{2}", org.CreateBy, org.OrgId, org.OrgCode); } } else { json.Add("createBy", ""); } json.Add("createTime", org.CreateDate); if (org.ModifyBy > 0) { User modefyBy = User.Retrieve(session, org.ModifyBy); if (modefyBy != null) { json.Add("modifyBy", string.IsNullOrEmpty(modefyBy.FullName) ? modefyBy.UserName : modefyBy.FullName); } else { Log.Warn <Org>("User {0} (ModifyBy) not found when loading org {1}:{2}", org.ModifyBy, org.OrgId, org.OrgCode); } } else { json.Add("modifyBy", ""); } json.Add("modifyTime", org.ModifyDate); User manager = null; if (org.Manager > 0) { manager = User.Retrieve(session, org.Manager); if (manager == null) { Log.Warn <Org>("User {0} (Manager) not found when loading org {1}:{2}", org.Manager, org.OrgId, org.OrgCode); } } if (manager != null) { json.Add("managerId", manager.UserId) .Add("manager", string.IsNullOrEmpty(manager.FullName) ? manager.UserName : manager.FullName); } else { json.Add("managerId", -1) .Add("manager", ""); } if (OrgTypeRegistry.HasExtAttr(org.OrgType) && org.ExtAttr != null) { Type type = OrgTypeRegistry.ExtAttrType(org.OrgType); org.ExtAttr.Json(session, json); } return(json); }
public static SimpleJson GetOrgJSON(ISession session, Org org) { SimpleJson json = new SimpleJson(); if (org == null) { json.HandleError("Org is null"); return json; } json.Add("id", org.OrgId) .Add("parent", org.ParentId) .Add("root", org.IsRoot) .Add("virtual", org.IsVirtual) .Add("seq", org.OrgSeq) .Add("code", org.OrgCode) .Add("name", org.OrgName) .Add("remark", org.Description) .Add("desc", org); if (org.CreateBy > 0) { User createBy = User.Retrieve(session, org.CreateBy); if (createBy != null) json.Add("createBy", string.IsNullOrEmpty(createBy.FullName) ? createBy.UserName : createBy.FullName); else Log.Warn<Org>("User {0} (CreateBy) not found when loading org {1}:{2}", org.CreateBy, org.OrgId, org.OrgCode); } else json.Add("createBy", ""); json.Add("createTime", org.CreateDate); if (org.ModifyBy > 0) { User modefyBy = User.Retrieve(session, org.ModifyBy); if (modefyBy != null) json.Add("modifyBy", string.IsNullOrEmpty(modefyBy.FullName) ? modefyBy.UserName : modefyBy.FullName); else Log.Warn<Org>("User {0} (ModifyBy) not found when loading org {1}:{2}", org.ModifyBy, org.OrgId, org.OrgCode); } else json.Add("modifyBy", ""); json.Add("modifyTime", org.ModifyDate); User manager = null; if (org.Manager > 0) { manager = User.Retrieve(session, org.Manager); if (manager == null) Log.Warn<Org>("User {0} (Manager) not found when loading org {1}:{2}", org.Manager, org.OrgId, org.OrgCode); } if (manager != null) json.Add("managerId", manager.UserId) .Add("manager", string.IsNullOrEmpty(manager.FullName) ? manager.UserName : manager.FullName); else json.Add("managerId", -1) .Add("manager", ""); if (OrgTypeRegistry.HasExtAttr(org.OrgType) && org.ExtAttr != null) { Type type = OrgTypeRegistry.ExtAttrType(org.OrgType); org.ExtAttr.Json(session, json); } return json; }