예제 #1
0
        public BizLogicMsg Save_Prd_Ext(string strJson)
        {
            if (LocalMode)
            {
                string strUserID   = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;
                string strUserName = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.NAME;

                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            DateTime dtCur = DateTime.Now;

                            List <EntityObject_PRV_D_DEPT> listPrd = JsonConvert.DeserializeObject <List <EntityObject_PRV_D_DEPT> >(strJson);

                            List <string> listPrdId = new List <string>();
                            foreach (EntityObject_PRV_D_DEPT entityObject_PRV_D_DEPT in listPrd)
                            {
                                CauseObject_MDM_D_DEPT pMDM_D_DEPT = new CauseObject_MDM_D_DEPT();
                                pMDM_D_DEPT.CODE         = entityObject_PRV_D_DEPT.CODE;
                                pMDM_D_DEPT.AUDIT_STATE  = "COM_1002_01";
                                pMDM_D_DEPT.DEPT_TYPE_ID = "00340003";

                                DisplayObject_MDM_D_DEPT[] listMDM_D_DEPT = BizLogicObject_MDM_D_DEPT.Proxy.Query(pMDM_D_DEPT);

                                if (listMDM_D_DEPT != null && listMDM_D_DEPT.Length > 0)
                                {
                                    continue;
                                }

                                if (!listPrdId.Contains(entityObject_PRV_D_DEPT.ID))
                                {
                                    listPrdId.Add(entityObject_PRV_D_DEPT.ID);
                                }
                                else
                                {
                                    continue;
                                }

                                EntityObject_MDM_D_DEPT entityPrd = new Entity.EntityObject_MDM_D_DEPT();

                                entityPrd.CODE            = entityObject_PRV_D_DEPT.CODE;
                                entityPrd.NAME            = entityObject_PRV_D_DEPT.NAME;
                                entityPrd.SHORT_NAME      = Ipedf.Core.ChineseHelper.GetChineseSpell(entityObject_PRV_D_DEPT.NAME);
                                entityPrd.BALANCE_TYPE_ID = entityObject_PRV_D_DEPT.BALANCE_TYPE_ID;
                                entityPrd.ADDRESS         = entityObject_PRV_D_DEPT.ADDRESS;
                                entityPrd.LINK_PERSON     = entityObject_PRV_D_DEPT.LINK_PERSON;

                                entityPrd.LAW_PERSON = entityObject_PRV_D_DEPT.LAW_PERSON;
                                entityPrd.SERVICES   = entityObject_PRV_D_DEPT.SERVICES;

                                entityPrd.PHONE = entityObject_PRV_D_DEPT.PHONE;
                                entityPrd.EMAIL = entityObject_PRV_D_DEPT.EMAIL;

                                entityPrd.REGISTER_FUND = entityObject_PRV_D_DEPT.REGISTER_FUND;

                                entityPrd.CREATE_USER_ID = strUserID;
                                entityPrd.CREATE_TIME    = dtCur;
                                entityPrd.STATE          = 1;
                                entityPrd.DEPT_TYPE_ID   = "00340003";
                                entityPrd.AUDIT_STATE    = "COM_1002_01";
                                entityPrd.AUDIT_USER_ID  = strUserID;
                                entityPrd.AUDIT_TIME     = dtCur;

                                entityPrd.REF_ID = entityObject_PRV_D_DEPT.ID;

                                HelperObject_MDM_D_DEPT.Save(entityPrd, 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_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri))
                {
                    return(smgr.Service.Save_Prd_Ext(strJson));
                }
            }
        }
예제 #2
0
        public BizLogicMsg CancelPrvAudit(List <string> idList)
        {
            if (LocalMode)
            {
                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            string strUserID   = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;
                            string strUserName = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.NAME;


                            foreach (string strID in idList)
                            {
                                CauseObject_MDM_D_DEPT p = new CauseObject_MDM_D_DEPT();
                                p.REF_ID = strID;


                                DisplayObject_MDM_D_DEPT[] list_MDM_D_DEPT = BizLogicObject_MDM_D_DEPT.Proxy.Query(p);
                                if (list_MDM_D_DEPT != null && list_MDM_D_DEPT.Length > 0)
                                {
                                    string strPrvID = list_MDM_D_DEPT[0].ID;

                                    EntityObject_MDM_D_DEPT entity = new EntityObject_MDM_D_DEPT();
                                    entity.ID = strPrvID;

                                    entity = BizLogicObject_MDM_D_DEPT.Proxy.Get(entity);

                                    if (entity != null)
                                    {
                                        entity.AUDIT_STATE   = "COM_1002_02";
                                        entity.AUDIT_TIME    = DateTime.Now;
                                        entity.AUDIT_USER_ID = strUserID;


                                        BizLogicObject_MDM_D_DEPT.Proxy.Update(entity);
                                    }
                                }

                                if (!msg.Succeed)
                                {
                                    throw new Exception(msg.Message);
                                }
                            }


                            transaction.Commit();


                            string strJson = JsonConvert.SerializeObject(idList);

                            Ipedf.Hrp.BizLogic.PRV_MCE_Web_Service.PRV_Web_Service service = new Ipedf.Hrp.BizLogic.PRV_MCE_Web_Service.PRV_Web_Service();
                            if (System.Configuration.ConfigurationManager.AppSettings["PrvMceWebServiceAddress"] != null)
                            {
                                string strServiceURL = System.Configuration.ConfigurationManager.AppSettings["PrvMceWebServiceAddress"];
                                service.Url = strServiceURL;
                            }
                            service.SetPrvAuditStatus(strJson, "COM_1002_02", strUserID, strUserName);
                        }
                        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_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri))
                {
                    return(smgr.Service.CancelPrvAudit(idList));
                }
            }
        }
예제 #3
0
        public BizLogicMsg Save_Dept_Ext(List <string> idList)
        {
            if (LocalMode)
            {
                string strUserID   = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;
                string strUserName = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.NAME;

                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            DateTime dtCur = DateTime.Now;

                            Ipedf.Hrp.BizLogic.PRV_MCE_Web_Service.PRV_Web_Service service = new Ipedf.Hrp.BizLogic.PRV_MCE_Web_Service.PRV_Web_Service();
                            if (System.Configuration.ConfigurationManager.AppSettings["PrvMceWebServiceAddress"] != null)
                            {
                                string strServiceURL = System.Configuration.ConfigurationManager.AppSettings["PrvMceWebServiceAddress"];
                                service.Url = strServiceURL;
                            }

                            foreach (string strID in idList)
                            {
                                string            strRegionAccount = service.GetAccountInfo(strID);
                                JsonRegionAccount regionAccount    = (JsonConvert.DeserializeObject <JsonRegionAccount>(strRegionAccount));



                                CauseObject_MDM_D_DEPT pMDM_D_DEPT = new CauseObject_MDM_D_DEPT();
                                pMDM_D_DEPT.CODE        = regionAccount.code;
                                pMDM_D_DEPT.AUDIT_STATE = "COM_1002_01";

                                DisplayObject_MDM_D_DEPT[] listMDM_D_DEPT = BizLogicObject_MDM_D_DEPT.Proxy.Query(pMDM_D_DEPT);

                                if (listMDM_D_DEPT != null && listMDM_D_DEPT.Length > 0)
                                {
                                    throw new Exception("企业代码" + pMDM_D_DEPT.CODE + "已经存在.");
                                }

                                string strEnterPriseInfo = service.GetEnterPriseInfo(strID);
                                JsonRegionEnterPrise regionEnterPrise = (JsonConvert.DeserializeObject <JsonRegionEnterPrise>(strEnterPriseInfo));

                                string strPrvCertList = service.GetPrvCertList(strID);
                                List <DisplayObject_V_PRV_PRVCERT_INFO> listRegionCert = JsonConvert.DeserializeObject <List <DisplayObject_V_PRV_PRVCERT_INFO> >(strPrvCertList);


                                EntityObject_MDM_D_DEPT entityObject_PRV_D_DEPT = new Entity.EntityObject_MDM_D_DEPT();

                                entityObject_PRV_D_DEPT.CODE            = regionAccount.code;
                                entityObject_PRV_D_DEPT.NAME            = regionEnterPrise.name;
                                entityObject_PRV_D_DEPT.SHORT_NAME      = Ipedf.Core.ChineseHelper.GetChineseSpell(regionEnterPrise.name);
                                entityObject_PRV_D_DEPT.BALANCE_TYPE_ID = regionEnterPrise.balance_type_id;
                                entityObject_PRV_D_DEPT.ADDRESS         = regionEnterPrise.address;
                                entityObject_PRV_D_DEPT.LINK_PERSON     = regionEnterPrise.link_Person;

                                entityObject_PRV_D_DEPT.LAW_PERSON = regionEnterPrise.law_Person;
                                entityObject_PRV_D_DEPT.SERVICES   = regionEnterPrise.services;

                                entityObject_PRV_D_DEPT.PHONE = regionAccount.phone;
                                entityObject_PRV_D_DEPT.EMAIL = regionAccount.email;

                                entityObject_PRV_D_DEPT.REGISTER_FUND = regionEnterPrise.register_fund;

                                entityObject_PRV_D_DEPT.CREATE_USER_ID = strUserID;
                                entityObject_PRV_D_DEPT.CREATE_TIME    = dtCur;
                                entityObject_PRV_D_DEPT.STATE          = 1;
                                entityObject_PRV_D_DEPT.DEPT_TYPE_ID   = "00340005";
                                entityObject_PRV_D_DEPT.AUDIT_STATE    = "COM_1002_01";
                                entityObject_PRV_D_DEPT.AUDIT_USER_ID  = strUserID;
                                entityObject_PRV_D_DEPT.AUDIT_TIME     = dtCur;

                                entityObject_PRV_D_DEPT.REF_ID = strID;

                                HelperObject_MDM_D_DEPT.Save(entityObject_PRV_D_DEPT, transaction);

                                if (listRegionCert != null && listRegionCert.Count > 0)
                                {
                                    foreach (DisplayObject_V_PRV_PRVCERT_INFO regionCert in listRegionCert)
                                    {
                                        if (!string.IsNullOrEmpty(regionCert.SAVE_NAME))
                                        {
                                            EntityObject_MTR_B_PRV_CERT pRV_B_PRV_CERT = new EntityObject_MTR_B_PRV_CERT();
                                            pRV_B_PRV_CERT.NATURE_ID   = "MTR_20010001";
                                            pRV_B_PRV_CERT.TYPE_ID     = regionCert.TYPE_ID;
                                            pRV_B_PRV_CERT.NAME        = regionCert.NAME;
                                            pRV_B_PRV_CERT.BEGIN_DATE  = regionCert.BEGIN_DATE;
                                            pRV_B_PRV_CERT.END_DATE    = regionCert.END_DATE;
                                            pRV_B_PRV_CERT.USER_ID     = strUserID;
                                            pRV_B_PRV_CERT.CREATE_DATE = dtCur;
                                            pRV_B_PRV_CERT.PRV_ID      = entityObject_PRV_D_DEPT.ID;
                                            pRV_B_PRV_CERT.REF_ID      = regionCert.ID;
                                            HelperObject_MTR_B_PRV_CERT.Save(pRV_B_PRV_CERT, transaction);

                                            if (!string.IsNullOrEmpty(regionCert.SAVE_NAME))
                                            {
                                                string aLastName = System.IO.Path.GetExtension(regionCert.SAVE_NAME).ToLower();

                                                try
                                                {
                                                    WebClient client = new WebClient();

                                                    string       strNetaddress = regionCert.SAVE_NAME;
                                                    byte[]       bytes         = client.DownloadData(new Uri(strNetaddress));
                                                    MemoryStream ms            = new MemoryStream(bytes);
                                                    ms.Seek(0, SeekOrigin.Begin);

                                                    //  string strFileExt = c.PICFILENAME.Substring(1 + c.PICFILENAME.LastIndexOf("."));
                                                    string strPicName = Guid.NewGuid().ToString() + aLastName;

                                                    string folder = "mce\\";

                                                    string uploadPath = HttpRuntime.AppDomainAppPath.ToString();

                                                    if (uploadPath.EndsWith("\\"))
                                                    {
                                                        uploadPath = uploadPath + "upload\\" + folder;
                                                    }
                                                    else
                                                    {
                                                        uploadPath = uploadPath + "\\upload\\" + folder;
                                                    }


                                                    uploadPath = uploadPath + strPicName;



                                                    FileStream fs = new FileStream(uploadPath, FileMode.Create);

                                                    //将byte数组写入文件中
                                                    fs.Write(bytes, 0, bytes.Length);
                                                    //所有流类型都要关闭流,否则会出现内存泄露问题
                                                    fs.Close();


                                                    byte[] photo      = new byte[] { }; //原图
                                                    byte[] thumbPhoto = new byte[] { }; //缩略图

                                                    EntityObject_MTR_FILE prv_File = new EntityObject_MTR_FILE();
                                                    prv_File.SAVE_NAME    = strPicName;
                                                    prv_File.FILE_NAME    = strPicName;
                                                    prv_File.REF_TAB_NAME = "MTR_B_PRV_CERT";
                                                    prv_File.REF_TAB_ID   = pRV_B_PRV_CERT.ID;
                                                    prv_File.SUFFIX       = aLastName;

                                                    prv_File.THUMB_BINARY = thumbPhoto;
                                                    prv_File.FILE_BINARY  = photo;


                                                    HelperObject_MTR_FILE.Save(prv_File, transaction);
                                                }
                                                catch
                                                {
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            string strJson = JsonConvert.SerializeObject(idList);
                            int    intRet  = service.SetPrvAuditStatus(strJson, "COM_1002_01", strUserID, strUserName);

                            if (intRet == 0)
                            {
                                throw new Exception("更新供应商端状态错误.");
                            }

                            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_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri))
                {
                    return(smgr.Service.Save_Dept_Ext(idList));
                }
            }
        }
예제 #4
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;

                //  string strID = request["id"].ToString();


                StringBuilder rsb       = new StringBuilder();
                int           bytelengg = (int)request.InputStream.Length;
                using (var reader = new StreamReader(request.InputStream, Encoding.UTF8))
                {
                    var read  = new Char[bytelengg];
                    var count = reader.Read(read, 0, bytelengg);
                    while (count > 0)
                    {
                        var str = new string(read, 0, count);
                        rsb.Append(str);
                        count = reader.Read(read, 0, bytelengg);
                    }
                    reader.Close();
                    reader.Dispose();
                    request.InputStream.Close();
                    request.InputStream.Dispose();
                }
                List <string> idList = JsonConvert.DeserializeObject <List <string> >(rsb.ToString());


                foreach (string strID in idList)
                {
                    CauseObject_MDM_D_DEPT p = new CauseObject_MDM_D_DEPT();
                    p.REF_ID      = strID;
                    p.AUDIT_STATE = "COM_1002_01";
                    DisplayObject_MDM_D_DEPT[] listExist = BizLogicObject_MDM_D_DEPT.Proxy.Query(p);
                    if (listExist != null && listExist.Length > 0)
                    {
                        throw new Exception("供应商" + listExist[0].NAME + "已经审核.");
                    }
                }



                BizLogicMsg msg = BizLogicObject_MCE_D_MCE_TYPE.Proxy.Save_Dept_Ext(idList);
                if (!msg.Succeed)
                {
                    throw new Exception(msg.Message);
                }

                jsonMsg.Succeed = 1;
            }
            catch (Exception ex)
            {
                jsonMsg.Succeed = 0;
                jsonMsg.Message = ex.Message;
            }
            finally
            {
                context.Response.Write(JsonConvert.SerializeObject(jsonMsg));
                context.Response.End();
            }
        }
        public BizLogicMsg Save_Ext(JsonMCE_PURCHASE_PLAN json)
        {
            if (LocalMode)
            {
                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            EntityObject_MCE_B_ASSETS_PURCHASE_PLAN entity = new EntityObject_MCE_B_ASSETS_PURCHASE_PLAN();


                            if (!string.IsNullOrEmpty(json.ID))
                            {
                                entity.ID = json.ID;

                                entity = HelperObject_MCE_B_ASSETS_PURCHASE_PLAN.Get(entity);

                                if (entity == null)
                                {
                                    throw new Exception("获取数据出错.");
                                }
                            }


                            entity.CODE          = json.CODE;
                            entity.APPLY_DEPT_ID = json.APPLY_DEPT_ID;
                            entity.APPLY_USER_ID = json.APPLY_USER_ID;
                            entity.PRV_ID        = json.PRV_ID;
                            entity.PRV_NAME      = json.PRV_NAME;

                            if (!string.IsNullOrEmpty(json.CREATE_DATE))
                            {
                                entity.CREATE_DATE = DateTime.Parse(json.CREATE_DATE);
                            }
                            entity.PURCHASE_DEPT_ID = json.PURCHASE_DEPT_ID;
                            entity.APPLY_USER_ID    = json.APPLY_USER_ID;

                            entity.COMMENTS = json.COMMENTS;



                            entity.STATE = 1;

                            if (string.IsNullOrEmpty(json.ID))
                            {
                                entity.CREATE_TIME    = DateTime.Now;
                                entity.CREATE_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;
                                entity.CREATE_DEPT_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.DEPART_ID;
                                int amount = HelperObject_MCE_B_ASSETS_PURCHASE_PLAN.Save(entity, transaction);
                            }
                            else
                            {
                                entity.MODIFY_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;
                                entity.MODIFY_DEPT_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.DEPART_ID;
                                int amount = HelperObject_MCE_B_ASSETS_PURCHASE_PLAN.Update(entity, transaction);
                            }


                            if (json.DELETEIDS != null && json.DELETEIDS.Count > 0)
                            {
                                foreach (string strID in json.DELETEIDS)
                                {
                                    EntityObject_MCE_B_ASSETS_PURCHASE_PLAN_D entity_D = new EntityObject_MCE_B_ASSETS_PURCHASE_PLAN_D();

                                    if (!string.IsNullOrEmpty(strID))
                                    {
                                        entity_D.ID = strID;

                                        entity_D = HelperObject_MCE_B_ASSETS_PURCHASE_PLAN_D.Get(entity_D);

                                        if (entity_D == null)
                                        {
                                            throw new Exception("获取数据出错.");
                                        }
                                        else
                                        {
                                            HelperObject_MCE_B_ASSETS_PURCHASE_PLAN_D.Delete(entity_D, transaction);
                                        }
                                    }
                                }
                            }

                            if (json.children != null && json.children.Count > 0)
                            {
                                decimal decTotMoney = 0;
                                foreach (JsonMCE_PURCHASE_PLAN_D item in json.children)
                                {
                                    EntityObject_MCE_B_ASSETS_PURCHASE_PLAN_D entity_D = new EntityObject_MCE_B_ASSETS_PURCHASE_PLAN_D();

                                    if (!string.IsNullOrEmpty(item.ID))
                                    {
                                        entity_D.ID = item.ID;

                                        entity_D = HelperObject_MCE_B_ASSETS_PURCHASE_PLAN_D.Get(entity_D);

                                        if (entity_D == null)
                                        {
                                            throw new Exception("获取数据出错.");
                                        }
                                    }

                                    entity_D.BASE_ID = entity.ID;

                                    entity_D.TYPE_ID    = item.TYPE_ID;
                                    entity_D.ASSETS_ID  = item.ASSETS_ID;
                                    entity_D.ASSET_NAME = item.ASSET_NAME;
                                    entity_D.SPEC       = item.SPEC;

                                    if (string.IsNullOrEmpty(item.ID))
                                    {
                                        if (!string.IsNullOrEmpty(item.PRD_ID))
                                        {
                                            string strPrdID          = "";
                                            CauseObject_MDM_D_DEPT p = new CauseObject_MDM_D_DEPT();
                                            p.REF_ID = item.PRD_ID;

                                            DisplayObject_MDM_D_DEPT[] listPrd = HelperObject_MDM_D_DEPT.Query(p);
                                            if (listPrd != null && listPrd.Length > 0)
                                            {
                                                strPrdID = listPrd[0].ID;
                                            }

                                            entity_D.PRD_ID = strPrdID;
                                        }
                                        entity_D.REF_PRD_ID = item.PRD_ID;
                                    }



                                    entity_D.PRD_NAME = item.PRD_NAME;
                                    entity_D.PRICE    = item.PRICE;
                                    entity_D.AMOUNT   = item.AMOUNT;
                                    entity_D.UNIT_ID  = item.UNIT_ID;

                                    entity_D.REF_TAB_ID   = item.REF_TAB_ID;
                                    entity_D.REF_TAB_NAME = item.REF_TAB_NAME;

                                    entity_D.MONEY = item.AMOUNT * item.PRICE;
                                    decTotMoney    = decTotMoney + entity_D.MONEY;

                                    if (string.IsNullOrEmpty(item.ID))
                                    {
                                        HelperObject_MCE_B_ASSETS_PURCHASE_PLAN_D.Save(entity_D, transaction);
                                    }
                                    else
                                    {
                                        HelperObject_MCE_B_ASSETS_PURCHASE_PLAN_D.Update(entity_D, transaction);
                                    }
                                }
                                entity.APPLY_MONEY = decTotMoney;

                                HelperObject_MCE_B_ASSETS_PURCHASE_PLAN.Update(entity, transaction);
                            }

                            msg.Message = entity.ID;

                            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_PURCHASE_PLAN> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_PURCHASE_PLAN>(ServiceUri))
                {
                    return(smgr.Service.Save_Ext(json));
                }
            }
        }
예제 #6
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;

                StringBuilder rsb       = new StringBuilder();
                int           bytelengg = (int)request.InputStream.Length;
                using (var reader = new StreamReader(request.InputStream, Encoding.UTF8))
                {
                    var read  = new Char[bytelengg];
                    var count = reader.Read(read, 0, bytelengg);
                    while (count > 0)
                    {
                        var str = new string(read, 0, count);
                        rsb.Append(str);
                        count = reader.Read(read, 0, bytelengg);
                    }
                    reader.Close();
                    reader.Dispose();
                    request.InputStream.Close();
                    request.InputStream.Dispose();
                }

                if (string.IsNullOrEmpty(rsb.ToString()))
                {
                    throw new Exception("参数错误.");
                }

                JsonMCE_PURCHASE json = JsonConvert.DeserializeObject <JsonMCE_PURCHASE>(rsb.ToString());


                if (string.IsNullOrEmpty(json.CODE))
                {
                    throw new Exception("参数错误,单号不能为空.");
                }

                if (json.APPLY_AMOUNT <= 0)
                {
                    throw new Exception("参数错误,请输入正确的申购数量.");
                }

                if (json.APPLY_MONEY <= 0)
                {
                    throw new Exception("参数错误,请输入正确预算金额.");
                }

                EntityObject_MCE_B_ASSETS_PURCHASE entity = new EntityObject_MCE_B_ASSETS_PURCHASE();
                entity.ID = json.ID;

                if (!string.IsNullOrEmpty(entity.ID))
                {
                    entity = BizLogicObject_MCE_B_ASSETS_PURCHASE.Proxy.Get(entity);

                    if (entity == null)
                    {
                        throw new Exception("获取数据出错.");
                    }
                }



                entity.CODE = json.CODE;

                entity.APPLY_AMOUNT = json.APPLY_AMOUNT;
                entity.APPLY_MONEY  = json.APPLY_MONEY;
                entity.APPLY_PRICE  = json.APPLY_PRICE;
                entity.TYPE_ID      = json.TYPE_ID;
                entity.ASSET_ID     = json.ASSET_ID;
                entity.ASSET_NAME   = json.ASSET_NAME;
                entity.SPEC         = json.SPEC;
                entity.CURRENCY_ID  = json.CURRENCY_ID;
                entity.UNIT_ID      = json.UNIT_ID;
                entity.UNIT_NAME    = json.UNIT_ID_NAME;



                if (string.IsNullOrEmpty(json.ID))
                {
                    if (!string.IsNullOrEmpty(json.PRD_ID))
                    {
                        string strPrdID          = "";
                        CauseObject_MDM_D_DEPT p = new CauseObject_MDM_D_DEPT();
                        p.REF_ID = json.PRD_ID;

                        DisplayObject_MDM_D_DEPT[] listPrd = BizLogicObject_MDM_D_DEPT.Proxy.Query(p);
                        if (listPrd != null && listPrd.Length > 0)
                        {
                            strPrdID = listPrd[0].ID;
                        }

                        entity.PRD_ID = strPrdID;
                    }

                    entity.REF_PRD_ID = json.PRD_ID;

                    if (!string.IsNullOrEmpty(json.PRV_ID))
                    {
                        string strPrvID = "";

                        CauseObject_MDM_D_DEPT p = new CauseObject_MDM_D_DEPT();
                        p.REF_ID = json.PRV_ID;

                        DisplayObject_MDM_D_DEPT[] listPrv = BizLogicObject_MDM_D_DEPT.Proxy.Query(p);
                        if (listPrv != null && listPrv.Length > 0)
                        {
                            strPrvID = listPrv[0].ID;
                        }

                        entity.PRV_ID = strPrvID;
                    }

                    entity.REF_PRV_ID = json.PRV_ID;
                }

                entity.PRD_NAME = json.PRD_ID_NAME;
                entity.PRV_NAME = json.PRV_ID_NAME;

                entity.PURCHASE_TYPE_ID = json.PURCHASE_TYPE_ID;
                entity.COMMENTS         = json.COMMENTS;

                entity.STATE = 1;
                entity.ID    = json.ID;
                entity.ID    = json.ID;

                BizLogicMsg msg = new BizLogicMsg();

                if (string.IsNullOrEmpty(entity.ID))
                {
                    entity.APPLY_DEPT_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.DEPART_ID;
                    entity.APPLY_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;

                    entity.CREATE_DEPT_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.DEPART_ID;
                    entity.CREATE_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;

                    entity.CREATE_DATE = entity.CREATE_TIME = DateTime.Now;

                    msg = BizLogicObject_MCE_B_ASSETS_PURCHASE.Proxy.Save(entity);
                }
                else
                {
                    entity.MODIFY_DEPT_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.DEPART_ID;
                    entity.MODIFY_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;

                    entity.MODIFY_TIME = DateTime.Now;

                    msg = BizLogicObject_MCE_B_ASSETS_PURCHASE.Proxy.Update(entity);
                }

                if (!msg.Succeed)
                {
                    throw new Exception(msg.Message);
                }

                jsonMsg.Succeed = 1;
                jsonMsg.Message = msg.Message;
            }
            catch (Exception ex)
            {
                jsonMsg.Succeed = 0;
                jsonMsg.Message = ex.Message;
            }
            finally
            {
                context.Response.Write(JsonConvert.SerializeObject(jsonMsg));
                context.Response.End();
            }
        }