using System; using System.Collections.Generic; using System.Linq; using System.Text; using LYFZ.Model; using System.Drawing; using LYFZ.WinAPI; namespace LYFZ.Software.MainBusiness.CommonLogical { /// /// 成功登录后的操作类 /// public class SuccessfulLogin { static string companyName = null; public static string CompanyName { get { if(companyName==null&&CurrentCompanyInfoID!="") { companyName = new BLL.BLL_ErpCompanyInfo().GetModel("Company_DividedShop", CurrentCompanyInfoID ).Company_Name; } return companyName; } } private static Model_ErpUser loginUserModel = null; /// /// 登录用户信息Model /// public static Model_ErpUser LoginUserModel { get { return SuccessfulLogin.loginUserModel; } set { SuccessfulLogin.loginUserModel = value; } } static bool isRefreshSuccess = false; /// /// 是否刷新成功 /// public static bool IsRefreshSuccess { get { return SuccessfulLogin.isRefreshSuccess; } set { SuccessfulLogin.isRefreshSuccess = value; } } static LYFZ.Network.TCPNetworkClient.TCP_NetworkClient tcpClient = null; public static LYFZ.Network.TCPNetworkClient.TCP_NetworkClient TcpClient { get { if (tcpClient == null) { tcpClient = new Network.TCPNetworkClient.TCP_NetworkClient(); } if (tcpClient.AppState!= HPSocketCS.Extended.AppState.Started) { tcpClient.ConnectionServer(); SuccessfulLogin.isRefreshSuccess = tcpClient.RefreshClientList(); LYFZ.PhotoSelectSystem.PhotoImportExport.CurrentNetworkClient = SuccessfulLogin.tcpClient; HPSocketCS.Extended.HP_SQLHelper.HpClient = SuccessfulLogin.tcpClient.Client; } return SuccessfulLogin.tcpClient; } set { SuccessfulLogin.tcpClient = value; LYFZ.PhotoSelectSystem.PhotoImportExport.CurrentNetworkClient = SuccessfulLogin.tcpClient; HPSocketCS.Extended.HP_SQLHelper.HpClient = SuccessfulLogin.tcpClient.Client; } } /// /// 用户是否成功登录 /// public static bool IsSuccessfulLogin { get { if (SuccessfulLogin.loginUserModel == null) { return false; } else { return true; } } } private static Image headImge = null; /// /// 用户头像图片 /// public static Image HeadImge { get { try { if (SuccessfulLogin.headImge == null) { SuccessfulLogin.headImge = LYFZ.ComponentLibrary.GetUIResources.df_WeddingHeadPortrait; } } catch { SuccessfulLogin.headImge = LYFZ.Software.UI.Properties.Resources.Tx19; } return SuccessfulLogin.headImge; } set { SuccessfulLogin.headImge = value; } } private static Bitmap loginBackgroundImage = null; /// /// 登录背景图 /// public static Bitmap LoginBackgroundImage { get { return SuccessfulLogin.loginBackgroundImage; } set { SuccessfulLogin.loginBackgroundImage = value; } } /// /// 是否开启写真版 /// public static bool IsEnablePhotoEdition { get { return LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsEnablePhotoEdition; } } /// /// 获取业务类型 只返回 BusinessType.婚纱版、BusinessType.儿童版、BusinessType.旗舰版 /// /// public static LYFZ.Software.MainBusiness.EnumPermissions.BusinessType GetBusinessType() { EnumPermissions.BusinessType buType = (EnumPermissions.BusinessType)SoftwareInfo.BusinessType; return buType; } /// /// 获取软件功能类型 只返回 FeatureType.集团版、FeatureType.全能版、FeatureType.坐席版 /// /// public static LYFZ.Software.MainBusiness.EnumPermissions.FeatureType GetFeatureType() { EnumPermissions.FeatureType featureType = (EnumPermissions.FeatureType)SoftwareInfo.FunctionType; return featureType; } /// /// 是否为集团版 /// public static bool IsGroupEdition { get { if (GetFeatureType() == EnumPermissions.FeatureType.集团总店 || GetFeatureType() == EnumPermissions.FeatureType.集团分店) { return true; } else { return false; } } } /// /// 获取软件功能版本列表 /// /// public static List GetBusinessTypeList() { List btypeList = new List(); switch (GetBusinessType()) { case EnumPermissions.BusinessType.婚纱版: btypeList.Add(EnumPermissions.BusinessType.婚纱版); break; case EnumPermissions.BusinessType.儿童版: btypeList.Add(EnumPermissions.BusinessType.儿童版); break; case 0: return btypeList; default: btypeList.Add(EnumPermissions.BusinessType.婚纱版); btypeList.Add(EnumPermissions.BusinessType.儿童版); break; } if (IsEnablePhotoEdition) { btypeList.Add(EnumPermissions.BusinessType.写真版); } return btypeList; } /// /// 获取软件功能版本列表 /// /// public static List GetBusinessTypeToIntList() { List typeList = GetBusinessTypeList(); List retList = new List(); foreach (EnumPermissions.BusinessType type in typeList) { retList.Add((int)type); } return retList; } #region 从服务器获取相片保存路径 /// /// 获取导入相片目录路径 /// /// 订单类型 /// 导入相片类别 /// 当前订单号 /// 景点名(拍摄阶段名) 导入原片时传入 /// public static System.IO.DirectoryInfo GetImportPhotoPath(LYFZ.EnumPublic.OrderType oType, LYFZ.BLL.SelectPhotoHandling.ImportExportType type, string orderNumber, string sightsName = null) { string dirPath = null; System.IO.DirectoryInfo dinfo = null; if (LYFZ.WinAPI.CustomPublicMethod.CheckInternaNetworkAddress(LYFZ.BLL.SelectPhotoHandling.ServerSddress)) { switch (type) { case BLL.SelectPhotoHandling.ImportExportType.PrimitivePicture: dirPath = GetPrimitivePicture(); break; case BLL.SelectPhotoHandling.ImportExportType.EarlyRetouch: dirPath = GetEarlyRetouch(); break; case BLL.SelectPhotoHandling.ImportExportType.FineRetouch: dirPath = GetFineRetouch(); break; case BLL.SelectPhotoHandling.ImportExportType.DesignPiece: dirPath = GetDesignPiece(); break; case BLL.SelectPhotoHandling.ImportExportType.NemoN8UserDirectory: dirPath = GetN8UserDirectory(); break; default: break; } } else if (BLL.SelectPhotoHandling.ISOpenLocalImportPhoto)//如果是在外网时,且开启本地导片功能时获取本地导片路径 { string dirName = "未知文件夹"; switch (type) { case BLL.SelectPhotoHandling.ImportExportType.PrimitivePicture: dirName = LYFZ.BLL.BLL_SystemGlobalSetting.GetParentDirectoryName(Model.Model_ErpOrder.DirectoryType.PrimitivePicture); break; case BLL.SelectPhotoHandling.ImportExportType.EarlyRetouch: dirName = LYFZ.BLL.BLL_SystemGlobalSetting.GetParentDirectoryName(Model.Model_ErpOrder.DirectoryType.EarlyRetouch); break; case BLL.SelectPhotoHandling.ImportExportType.FineRetouch: dirName = LYFZ.BLL.BLL_SystemGlobalSetting.GetParentDirectoryName(Model.Model_ErpOrder.DirectoryType.FineRetouch); break; case BLL.SelectPhotoHandling.ImportExportType.DesignPiece: dirName = LYFZ.BLL.BLL_SystemGlobalSetting.GetParentDirectoryName(Model.Model_ErpOrder.DirectoryType.DesignPiece); break; case BLL.SelectPhotoHandling.ImportExportType.NemoN8UserDirectory: dirPath = GetN8UserDirectory(); break; } dirPath = LYFZ.WinAPI.CustomPublicMethod.GetFullDirectoryPath(BLL.SelectPhotoHandling.LocalImportDirectoryPath) + dirName; } if (dirPath != null) { dirPath = LYFZ.BLL.SelectPhotoHandling.GetFullPath(dirPath) + orderNumber + "\\"; if (type == BLL.SelectPhotoHandling.ImportExportType.PrimitivePicture || oType == EnumPublic.OrderType.儿童订单) { if (sightsName == null || sightsName.Trim().Length <= 0) { sightsName = "未知拍摄"; } dirPath = LYFZ.BLL.SelectPhotoHandling.GetFullPath(dirPath) + sightsName + "\\"; } if (!System.IO.Directory.Exists(dirPath)) { try { dinfo = System.IO.Directory.CreateDirectory(dirPath); } catch (Exception ex) { MessageBoxCustom.Show("相片目录路径读取失败,请检查相片共享目录和权限设置。错误原因:" + ex.Message); } } else { dinfo = new System.IO.DirectoryInfo(dirPath); } } else { MessageBoxCustom.Show("相片目录获取失败,请在服务器端设置正确的共享目后重试!"); } return dinfo; } /// /// 获取导入原片目录 /// static string GetPrimitivePicture() { string tempPath = null; if (tcpClient != null) { tempPath = tcpClient.SendCommandToServer(HPSocketCS.Extended.TransferRequestCommand.GetSavePath, LYFZ.Model.Model_ServerConfig.PhotoDirectoryCategory.原片保存目录.ToString()).Split('|')[1]; tempPath = GetFullServerPath(LYFZ.BLL.SelectPhotoHandling.ImportExportType.PrimitivePicture, tempPath); } return tempPath; } /// /// 获取相片保存路径集合 用于客户端读取订单相片 /// public static void GetRedPhotoFilePathList() { if (tcpClient != null) { string tempPath = tcpClient.SendCommandToServer(HPSocketCS.Extended.TransferRequestCommand.GetSavePhotoPathList); LYFZ.BLL.RedPhotoFilePathList.CurrentRedPhotoFilePathList = new BLL.RedPhotoFilePathList(tempPath); } } /// /// 获取导入初修片目录 /// static string GetEarlyRetouch() { string tempPath = null; if (tcpClient != null) { tempPath = tcpClient.SendCommandToServer(HPSocketCS.Extended.TransferRequestCommand.GetSavePath, LYFZ.Model.Model_ServerConfig.PhotoDirectoryCategory.初修片保存目录.ToString()).Split('|')[1]; tempPath = GetFullServerPath(LYFZ.BLL.SelectPhotoHandling.ImportExportType.EarlyRetouch, tempPath); } return tempPath; } /// /// 获取导入精修片目录 /// static string GetFineRetouch() { string tempPath = null; if (tcpClient != null) { tempPath = tcpClient.SendCommandToServer(HPSocketCS.Extended.TransferRequestCommand.GetSavePath, LYFZ.Model.Model_ServerConfig.PhotoDirectoryCategory.精修片保存目录.ToString()).Split('|')[1]; tempPath = GetFullServerPath(LYFZ.BLL.SelectPhotoHandling.ImportExportType.FineRetouch, tempPath); } return tempPath; } /// /// 获取导入设计片目录 /// static string GetDesignPiece() { string tempPath = null; if (tcpClient != null) { tempPath = tcpClient.SendCommandToServer(HPSocketCS.Extended.TransferRequestCommand.GetSavePath, LYFZ.Model.Model_ServerConfig.PhotoDirectoryCategory.设计片保存目录.ToString()).Split('|')[1]; tempPath = GetFullServerPath(LYFZ.BLL.SelectPhotoHandling.ImportExportType.DesignPiece, tempPath); } return tempPath; } static string GetN8UserDirectory() { return LYFZ.Network.PlatinumClientProcess.N8SvrConfig.N8ServerUserDirectory; } /// /// 根据服务器返回路径获取完整的相关相片保存路径 /// /// /// /// static string GetFullServerPath(LYFZ.BLL.SelectPhotoHandling.ImportExportType type, string formServarPath) { // LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig(); string dirName = "未知文件夹\\"; switch (type) { case BLL.SelectPhotoHandling.ImportExportType.PrimitivePicture: dirName = LYFZ.BLL.BLL_SystemGlobalSetting.GetParentDirectoryName(Model.Model_ErpOrder.DirectoryType.PrimitivePicture); break; case BLL.SelectPhotoHandling.ImportExportType.EarlyRetouch: dirName = LYFZ.BLL.BLL_SystemGlobalSetting.GetParentDirectoryName(Model.Model_ErpOrder.DirectoryType.EarlyRetouch); break; case BLL.SelectPhotoHandling.ImportExportType.FineRetouch: dirName = LYFZ.BLL.BLL_SystemGlobalSetting.GetParentDirectoryName(Model.Model_ErpOrder.DirectoryType.FineRetouch); break; case BLL.SelectPhotoHandling.ImportExportType.DesignPiece: dirName = LYFZ.BLL.BLL_SystemGlobalSetting.GetParentDirectoryName(Model.Model_ErpOrder.DirectoryType.DesignPiece); break; case BLL.SelectPhotoHandling.ImportExportType.NemoN8UserDirectory: dirName = LYFZ.Network.PlatinumClientProcess.N8SvrConfig.N8ServerUserDirectory; break; default: break; } if (formServarPath != null) { if (formServarPath.Trim() != "非共享目录") { if (formServarPath.IndexOf("\\\\") == -1) { formServarPath = "\\\\" + LYFZ.BLL.SelectPhotoHandling.ServerSddress + "\\" + formServarPath + "\\" + dirName; } else { formServarPath = LYFZ.BLL.SelectPhotoHandling.GetFullPath(formServarPath); formServarPath = formServarPath + dirName; } } else { formServarPath = null; } } return formServarPath; } #endregion #region 获取服务器上传文件路径 /// /// 获取导入报表模板图片 /// public static string GetReportModelPiece() { LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig(); string tempPath = "\\\\" + mConfig.ServerHostOrIP + "\\ShareDirectory$\\报表模板图片"; return tempPath; } /// /// 获取服务器资源共享文件目录 /// public static string GetShareDirectoryPath() { LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig(); string tempPath = "\\\\" + mConfig.ServerHostOrIP + "\\ShareDirectory$\\"; if (!System.IO.Directory.Exists(tempPath)) { System.IO.Directory.CreateDirectory(tempPath); } return tempPath; } /// /// 获取导入客户头像 /// /// public static string CustomerPicture() { LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig(); return "\\\\" + mConfig.ServerHostOrIP + "\\ShareDirectory$\\客户头像"; } /// /// 获取导入客户头像TCP路径 /// /// public static string TCP_CustomerPicture() { return "\\ShareDirectory$\\客户头像"; } /// /// 获取导入固定资产TCP路径 /// /// public static string TCP_FixedAsset() { return "\\UploadFiles\\FixedAsset"; } /// /// 获取来电精灵路径 /// /// public static string GetCallerWizardPath() { //string tempPath = null; //LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig(); //tempPath = @"\\" + mConfig.ServerHostOrIP + "\\来电精灵录音"; //return tempPath; LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig(); string tempPath = "\\\\" + mConfig.ServerHostOrIP + "\\ShareDirectory$\\来电精灵录音"; if (!System.IO.Directory.Exists(tempPath)) { if (LYFZ.WinAPI.CustomPublicMethod.CheckInternaNetworkAddress(mConfig.ServerHostOrIP)) { System.IO.Directory.CreateDirectory(tempPath); } } return tempPath; } /// /// 获取来电精灵路径 /// /// public static string TCP_GetCallerWizardPath() { return "\\ShareDirectory$\\来电精灵录音"; } /// /// 获取喜爱风格 /// /// public static string FavoriteStyle() { LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig(); if (LYFZ.WinAPI.CustomPublicMethod.CheckInternaNetworkAddress(mConfig.ServerHostOrIP)) { return "\\\\" + mConfig.ServerHostOrIP + "\\ShareDirectory$\\喜爱风格"; } else { return LYFZ.WinAPI.CustomPublicMethod.GetFullDirectoryPath(LYFZ.WinAPI.CustomPublicMethod.BasePath) + "\\ShareDirectory$\\喜爱风格"; } } /// /// 获取喜爱风格 /// /// public static string TCP_FavoriteStyle() { return "\\ShareDirectory$\\喜爱风格"; } /// /// 获取来电精灵路径 /// /// public static string TCP_EmployeesPhotoPath() { return "\\UploadFiles\\EmployeePhoto"; } /// /// 获取来电精灵路径 /// /// public static string TCP_FinancialOutlayReceipt() { return "\\UploadFiles\\FinancialOutlayReceipt"; } /// /// 获取景点文件路径 /// /// public static string SightsDirectoryPath() { LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig(); if (LYFZ.WinAPI.CustomPublicMethod.CheckInternaNetworkAddress(mConfig.ServerHostOrIP)) { return "\\\\" + mConfig.ServerHostOrIP + "\\ShareDirectory$\\Sights"; } else { return LYFZ.WinAPI.CustomPublicMethod.GetFullDirectoryPath(LYFZ.WinAPI.CustomPublicMethod.BasePath) + "\\ShareDirectory$\\Sights"; } } /// /// 获取景点文件路径 /// /// public static string TCP_SightsDirectoryPath() { return "\\ShareDirectory$\\Sights"; } /// /// 获取导入礼服TCP路径 /// /// public static string TCP_DressPhoto() { return "\\UploadFiles\\DressPhotos"; } /// /// 获取导入其他消费相片TCP路径 /// /// public static string TCP_OtherConsumePhoto() { return "\\UploadFiles\\OtherConsumePhotos"; } /// /// 获取导入医院相片TCP路径 /// /// public static string TCP_HospitalPhoto() { return "\\UploadFiles\\HospitalPhotos"; } #endregion /// /// 获取每页显示条数 /// /// public static int GetPageSize() { return LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ReportFormPageSize; } static LYFZ.Model.Model_SoftwareInfo _SoftwareInfo = new Model_SoftwareInfo(); /// /// 获取软件信息 /// public static LYFZ.Model.Model_SoftwareInfo SoftwareInfo { get { return SuccessfulLogin._SoftwareInfo; } set { SuccessfulLogin._SoftwareInfo = value; } } static string _user_ip = ""; /// /// 用IP /// public static string User_IP { set { _user_ip = value; } get { return _user_ip; } } /// /// 当前登录本店ID /// public static string CurrentCompanyInfoID = ""; /// /// 获取影楼店编号的ID /// /// public static string GetCompanyInfoID() { return CurrentCompanyInfoID;//"SSN001"; } /// /// 获取本地影楼店编号的ID 当前接单点ID /// /// public static string GetLocalCompanyInfoID() { string strNumber = CurrentCompanyInfoID; LYFZ.BLL.OrderPayment_Member.StrInfoID = strNumber; return strNumber; } /// /// 获取服务器当前时间对象 /// /// public static DateTime GetServerDateTime() { return SDateTime.Now; } /// /// 订单号的前缀 /// /// public static string GetPrefix(LYFZ.EnumPublic.OrderNumberPrefixType type = EnumPublic.OrderNumberPrefixType.其它消费) { string retPrefix = ""; switch (type) { case EnumPublic.OrderNumberPrefixType.婚纱订单: retPrefix = LYFZ.BLL.BLL_CurrentShopSetting.CurrentShopSet.OrdersNumberPrefixName.WeddingOrdersPrefix; break; case EnumPublic.OrderNumberPrefixType.儿童订单: retPrefix = LYFZ.BLL.BLL_CurrentShopSetting.CurrentShopSet.OrdersNumberPrefixName.ChildrensOrdersPrefix; break; case EnumPublic.OrderNumberPrefixType.写真订单: retPrefix = LYFZ.BLL.BLL_CurrentShopSetting.CurrentShopSet.OrdersNumberPrefixName.PhotoOrdersPrefix; break; case EnumPublic.OrderNumberPrefixType.婚庆订单: retPrefix = LYFZ.BLL.BLL_CurrentShopSetting.CurrentShopSet.OrdersNumberPrefixName.WeddingServicesPrefix; break; default: retPrefix = LYFZ.BLL.BLL_CurrentShopSetting.CurrentShopSet.OrdersNumberPrefixName.OtherAppointmentsPrefix; break; } return retPrefix; } /// /// 是否开启可自定义订单号 true:为可以 false:为不可能 /// 注:在开单的时候,是否可以输入自定义单号 /// /// public static bool IsCustomOrderNumber() { return LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsCustomOrderNumber; } /// /// 生成二维码 /// /// 要生成的文字或者数字,支持中文。如: "4408810820 深圳-广州" 或者:4444444444 /// 三种尺寸:BYTE ,ALPHA_NUMERIC,NUMERIC /// 大小:L M Q H /// 版本:如 8 /// 比例:如 4 /// public static Image CreateCode_Choose(string strData, string qrEncoding, string level, int version, int scale) { ThoughtWorks.QRCode.Codec.QRCodeEncoder qrCodeEncoder = new ThoughtWorks.QRCode.Codec.QRCodeEncoder(); //设置编码模式 string encoding = qrEncoding; switch (encoding) { case "Byte": qrCodeEncoder.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.BYTE; break; case "AlphaNumeric": qrCodeEncoder.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC; break; case "Numeric": qrCodeEncoder.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.NUMERIC; break; default: qrCodeEncoder.QRCodeEncodeMode = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.BYTE; break; } ////每个小方格的宽度 qrCodeEncoder.QRCodeScale = scale; //符号规格从版本1(21×21模块)到版本40(177×177 模块),每提高一个版本,每边增加4个模块 //数据类型与容量(参照最大规格符号版本40-L级) //数字数据:7,089个字符 //字母数据: 4,296个字符 //8位字节数据: 2,953个字符 //汉字数据:1,817个字符 qrCodeEncoder.QRCodeVersion = version; //设置编码错误纠正 //L级:约可纠错7%的数据码字 // M级:约可纠错15%的数据码字 //Q级:约可纠错25%的数据码字 // H级:约可纠错30%的数据码字 switch (level) { case "L": qrCodeEncoder.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.L; break; case "M": qrCodeEncoder.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.M; break; case "Q": qrCodeEncoder.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.Q; break; default: qrCodeEncoder.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.H; break; } //文字生成图片 Image image = qrCodeEncoder.Encode(strData); return image; } } }