Exemplo n.º 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));
                }
            }
        }
Exemplo n.º 2
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));
                }
            }
        }