private string GetMeterCode()
        {
            string strMeterCode = "";

            string strCode = DateTime.Now.ToString("yyyyMMdd");


            int code = 1;

            OrderByParameter orderBy = new OrderByParameter();

            orderBy.Asc     = false;
            orderBy.OrderBy = "CODE";

            var cause = new CauseObject_MCE_B_ASSETS_METER();

            cause.SetCustomCondition(" and MCE_B_ASSETS_METER.CODE like '" + strCode + "%'");
            var list = BizLogicObject_MCE_B_ASSETS_METER.Proxy.Query(cause, null, orderBy);

            if (list != null && list.Length > 0)
            {
                var s_code    = list[0].CODE;
                var rightCode = s_code.Replace(strCode, "").TrimStart('0');
                code = int.Parse(rightCode) + 1;
            }

            strMeterCode = strCode + (code).ToString().PadLeft(3, '0');

            return(strMeterCode);
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            //允许跨域
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            JSON_MSG jsonMsg = new JSON_MSG();

            try
            {
                context.Response.ContentType = "text/plain";
                HttpRequest request = context.Request;

                if (string.IsNullOrEmpty(request["id"]))
                {
                    throw new Exception("参数错误.");
                }

                CauseObject_MCE_B_ASSETS_METER p = new CauseObject_MCE_B_ASSETS_METER();
                p.ID = request["id"].ToString();

                DisplayObject_MCE_B_ASSETS_METER[] listHead = BizLogicObject_MCE_B_ASSETS_METER.Proxy.Query(p);


                JSON_PAGER jsonPager = new JSON_PAGER();
                if (listHead == null)
                {
                    throw new Exception("获取列表信息失败.");
                }

                jsonPager.head = listHead[0];



                jsonMsg.Succeed = 1;
                jsonMsg.Message = jsonPager;
            }
            catch (Exception ex)
            {
                jsonMsg.Succeed = 0;
                jsonMsg.Message = ex.Message;
            }
            finally
            {
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter {
                    DateTimeFormat = "yyyy'-'MM'-'dd HH':'mm"
                };

                string strMsg = JsonConvert.SerializeObject(jsonMsg, Formatting.Indented, timeConverter);
                strMsg = strMsg.Replace("0001-01-01 00:00", "");
                context.Response.Write(strMsg);


                context.Response.End();
            }
        }
Beispiel #3
0
 public int DeleteByTrans2(CauseObject_MCE_B_ASSETS_METER cause, IDbTransaction transaction)
 {
     if (LocalMode)
     {
         return(HelperObject_MCE_B_ASSETS_METER.Delete(cause, transaction));
         //平台自动生成代码
     }
     else
     {
         throw new InvalidConstraintException();
     }
 }
Beispiel #4
0
        public DisplayObject_MCE_B_ASSETS_METER[] Query(CauseObject_MCE_B_ASSETS_METER cause, PagingParamter paging, OrderByParameter order)
        {
            if (LocalMode)
            {
                SystemLogic.Proxy.AuditQuery(cause);

                //平台自动生成代码
                return(HelperObject_MCE_B_ASSETS_METER.Query(cause, paging, order));
            }
            else
            {
                using (ServiceManager <ServiceContract_MCE_B_ASSETS_METER> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_METER>(ServiceUri))
                {
                    return(smgr.Service.Query(cause, paging, order));
                }
            }
        }
Beispiel #5
0
 public BizLogicMsg Delete(CauseObject_MCE_B_ASSETS_METER cause)
 {
     if (LocalMode)
     {
         BizLogicMsg msg = new BizLogicMsg();
         using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
         {
             using (IDbTransaction transaction = connection.BeginTransaction())
             {
                 try
                 {
                     int amount = HelperObject_MCE_B_ASSETS_METER.Delete(cause, transaction);
                     //平台自动生成代码
                     transaction.Commit();
                 }
                 catch (Exception expt)
                 {
                     transaction.Rollback();
                     msg = new BizLogicMsg(false, expt.Message);
                     Error(expt);
                 }
                 finally
                 {
                     IDALProvider.IDAL.PushConnection(connection);
                 }
             }
         }
         return(msg);
     }
     else
     {
         using (ServiceManager <ServiceContract_MCE_B_ASSETS_METER> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_METER>(ServiceUri))
         {
             return(smgr.Service.Delete(cause));
         }
     }
 }
        public void ProcessRequest(HttpContext context)
        {
            //允许跨域
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            JSON_MSG jsonMsg = new JSON_MSG();

            try
            {
                context.Response.ContentType = "text/plain";
                HttpRequest request = context.Request;

                OrderByParameter orderBy = new OrderByParameter();
                orderBy.Asc     = false;
                orderBy.OrderBy = "CODE";

                PagingParamter pager = new PagingParamter();
                pager.PageSize  = string.IsNullOrEmpty(request["limit"]) ? 10 : int.Parse(request["limit"].ToString());
                pager.PageIndex = string.IsNullOrEmpty(request["offset"]) ? 0 : (int.Parse(request["offset"].ToString()) <= 0) ? 0 : int.Parse(request["offset"].ToString()) - 1;

                CauseObject_MCE_B_ASSETS_METER p = new CauseObject_MCE_B_ASSETS_METER();

                if (!string.IsNullOrEmpty(request["status"]))
                {
                    p.STATE = int.Parse(request["status"].ToString());
                }


                if (!string.IsNullOrEmpty(request["dept"]))
                {
                    p.USING_DEPT_ID = request["dept"].ToString();
                }


                if (!string.IsNullOrEmpty(request["asset"]))
                {
                    p.ASSETS_ID = request["asset"].ToString();
                }


                if (!string.IsNullOrEmpty(request["meter_type"]))
                {
                    p.METER_TYPE = request["meter_type"].ToString();
                }

                if (!string.IsNullOrEmpty(request["code"]))
                {
                    p.CODE = "%" + request["code"].ToString() + "%";
                }

                if (!string.IsNullOrEmpty(request["beginspan"]))
                {
                    p.NEXT_IDENTIFICATION       = new DateSpan();
                    p.NEXT_IDENTIFICATION.Begin = DateTime.Parse(request["beginspan"].ToString());
                }
                if (!string.IsNullOrEmpty(request["endspan"]))
                {
                    if (p.NEXT_IDENTIFICATION == null)
                    {
                        p.NEXT_IDENTIFICATION = new DateSpan();
                    }
                    p.NEXT_IDENTIFICATION.End = DateTime.Parse(request["endspan"].ToString());
                }


                DisplayObject_MCE_B_ASSETS_METER[] list = BizLogicObject_MCE_B_ASSETS_METER.Proxy.Query(p, pager, orderBy);



                JSON_PAGER jsonPager = new JSON_PAGER();

                jsonPager.total = pager.TotalRecords;
                jsonPager.rows  = list;

                jsonMsg.Message = jsonPager;
                jsonMsg.Succeed = 1;
            }
            catch (Exception ex)
            {
                jsonMsg.Succeed = 0;
                jsonMsg.Message = ex.Message;
            }
            finally
            {
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter {
                    DateTimeFormat = "yyyy'-'MM'-'dd HH':'mm"
                };

                string strMsg = JsonConvert.SerializeObject(jsonMsg, Formatting.Indented, timeConverter);
                strMsg = strMsg.Replace("0001-01-01 00:00", "");
                context.Response.Write(strMsg);

                context.Response.End();
            }
        }
Beispiel #7
0
        public void ProcessRequest(HttpContext context)
        {
            //允许跨域
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            JSON_MSG jsonMsg = new JSON_MSG();

            try
            {
                context.Response.ContentType = "text/plain";
                HttpRequest request = context.Request;


                if (string.IsNullOrEmpty(request["id"]))
                {
                    throw new Exception("参数错误.");
                }


                OrderByParameter orderBy = new OrderByParameter();
                orderBy.Asc     = true;
                orderBy.OrderBy = "CODE";

                StringBuilder strCondition       = new StringBuilder();
                CauseObject_MCE_B_ASSETS_METER p = new CauseObject_MCE_B_ASSETS_METER();

                p.ASSETS_ID = request["id"];

                if (!string.IsNullOrEmpty(request["condition"]))//
                {
                    strCondition.Append(" and (MCE_B_ASSETS_METER.CODE like '%" + request["condition"].ToString().Trim() + "%' )");
                }



                if (!string.IsNullOrEmpty(strCondition.ToString()))
                {
                    p.SetCustomCondition(strCondition.ToString());
                }

                DisplayObject_MCE_B_ASSETS_METER[] list = BizLogicObject_MCE_B_ASSETS_METER.Proxy.Query(p, null, orderBy);


                if (list != null && list.Length > 0)
                {
                    foreach (DisplayObject_MCE_B_ASSETS_METER item in list)
                    {
                        string strFiles = "";
                        CauseObject_COM_FILE pCOM_FILE = new CauseObject_COM_FILE();
                        pCOM_FILE.REF_TAB_ID   = item.ID;
                        pCOM_FILE.REF_TAB_NAME = "MCE_B_ASSETS_METER";

                        DisplayObject_COM_FILE[] listCOM_FILE = BizLogicObject_COM_FILE.Proxy.Query(pCOM_FILE);

                        if (listCOM_FILE != null && listCOM_FILE.Length > 0)
                        {
                            foreach (DisplayObject_COM_FILE file in listCOM_FILE)
                            {
                                if (!string.IsNullOrEmpty(file.SERVER_NAME))
                                {
                                    strFiles = strFiles + file.SERVER_NAME + "/" + file.CLIENT_NAME + ",";
                                }
                            }
                            strFiles = strFiles.TrimEnd(',');
                        }
                        item.BACKUP1 = strFiles;
                    }
                }


                jsonMsg.Message = list;
                jsonMsg.Succeed = 1;
            }
            catch (Exception ex)
            {
                jsonMsg.Succeed = 0;
                jsonMsg.Message = ex.Message;
            }
            finally
            {
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter {
                    DateTimeFormat = "yyyy'-'MM'-'dd HH':'mm"
                };

                string strMsg = JsonConvert.SerializeObject(jsonMsg, Formatting.Indented, timeConverter);
                strMsg = strMsg.Replace("0001-01-01 00:00", "");
                context.Response.Write(strMsg);

                context.Response.End();
            }
        }