コード例 #1
0
        private bool doupgradesql(HttpContext context, string ZipPath, string rootPath)
        {
            var    config      = new Utility.SiteConfig();
            string SiteName    = config.SiteName;
            string NewFileName = DateTime.Now.ToString("yyyyMMddHHmmss");

            Utility.Tools.UnZipFile(ZipPath, rootPath, NewFileName);
            string        DatabaseName = ConfigurationManager.AppSettings["DatabaseName"];
            string        FullFilePath = rootPath + NewFileName;
            DirectoryInfo root         = new DirectoryInfo(FullFilePath);

            foreach (FileInfo f in root.GetFiles().OrderBy(p => p.Name))
            {
                if (!f.Extension.ToLower().Contains("sql"))
                {
                    continue;
                }
                string SQLFullPath = FullFilePath + "\\" + f.Name;
                try
                {
                    Utility.SQLHelper.ExecuteSQLFile(SQLFullPath, DatabaseName);
                }
                catch (Exception ex)
                {
                    LogHelper.WriteError("更新数据库失败", "", ex);
                }
            }
            return(true);
        }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int BaoXiuServiceID = new Utility.SiteConfig().BaoXiuServiceID;
         var typeList        = Foresight.DataAccess.ServiceType.GetServiceTypes().ToArray();
         var typeList2       = typeList.Where(p => p.ParentID == BaoXiuServiceID).ToArray();
         var typeItems2      = typeList2.Select(p =>
         {
             var item = new { ID = p.ID, Name = p.ServiceTypeName };
             return(item);
         }).ToList();
         typeItems2.Insert(0, new { ID = 0, Name = "全部" });
         typeItems2.Insert(0, new { ID = -1, Name = "不限" });
         this.hdServiceTypeName2.Value = Utility.JsonConvert.SerializeObject(typeItems2);
         var typeList2IDList = typeList2.Select(p => p.ID).ToArray();
         var typeList3       = typeList.Where(p => typeList2IDList.Contains(p.ParentID)).ToArray();
         var typeItems3      = typeList3.Select(p =>
         {
             var item = new { ID = p.ID, Name = p.ServiceTypeName, ParentID = p.ParentID };
             return(item);
         }).ToList();
         this.hdServiceTypeName3.Value = Utility.JsonConvert.SerializeObject(typeItems3);
     }
 }
コード例 #3
0
        ///
        /// 处理文本消息
        ///
        ///消息对象
        ///参数(用于具体业务传递参数用)
        ///是否处理成功
        public bool ProcessTextMessage(TextReceiveMessage msg, params object[] args)
        {
            string response_msg = new Utility.SiteConfig().WechatAutoResponseMsg;

            MessageHandler.SendTextReplyMessage(msg.ToUserName, msg.FromUserName, response_msg);
            return(true);
        }
コード例 #4
0
        public static bool IsInternalSys(out string errormsg, out Company company, bool includedemo = true)
        {
            var siteConfig = new Utility.SiteConfig();

            errormsg = string.Empty;
            company  = null;
            string requestURL = WebUtil.GetContextPath();

            if (siteConfig.IsDemoSite && includedemo)
            {
                errormsg = "内部系统,无须审核";
                company  = Foresight.DataAccess.Company.GetCompanies().Where(p => p.BaseURL.Contains(WebUtil.GetContextPath())).FirstOrDefault();
                return(true);
            }
            if (siteConfig.IsAdminSite)
            {
                errormsg = "内部系统,无须审核";
                company  = Foresight.DataAccess.Company.GetCompanies().Where(p => p.BaseURL.Contains(WebUtil.GetContextPath())).FirstOrDefault();
                return(true);
            }
            if (requestURL.Contains("http://localhost"))
            {
                company  = Foresight.DataAccess.Company.GetCompanies().FirstOrDefault();
                errormsg = "本地系统,测试使用";
                return(true);
            }
            return(false);
        }
コード例 #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         var site_config = new Utility.SiteConfig();
         IsMallOn            = site_config.IsMallOn;
         IsMallBusinessOn    = site_config.IsMallBusinessOn;
         IsMallInHouseUserOn = site_config.IsMallInHouseUserOn;
         if (!string.IsNullOrEmpty(Request.QueryString["type"]))
         {
             int.TryParse(Request.QueryString["type"], out type);
         }
         if (!string.IsNullOrEmpty(Request.QueryString["msgtypeid"]))
         {
             int.TryParse(Request.QueryString["msgtypeid"], out msgtypeid);
         }
         if (!string.IsNullOrEmpty(Request.QueryString["MsgType"]))
         {
             MsgType = Request.QueryString["MsgType"];
         }
         var list       = Foresight.DataAccess.Wechat_MsgCategory.GetWechat_MsgCategories().OrderBy(p => p.SortOrder).ToArray();
         var list_items = list.Select(p =>
         {
             var item = new { ID = p.ID, CategoryName = p.CategoryName };
             return(item);
         });
         this.hdCategory.Value = JsonConvert.SerializeObject(list_items);
         int.TryParse(Request.QueryString["ID"], out ID);
         if (ID > 0)
         {
             var data = Foresight.DataAccess.Wechat_Msg.GetWechat_Msg(ID);
             if (data != null)
             {
                 SetInfo(data);
                 return;
             }
         }
         if (type == 1)
         {
             this.tdIsWechatSend.Checked = true;
         }
         if (type == 2)
         {
             this.tdIsCustomerAPPSend.Checked = true;
         }
         if (type == 3)
         {
             this.tdIsUserAPPSend.Checked = true;
         }
         this.tdPublishTime.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
     }
 }
コード例 #6
0
        public static int GetFromCompanyID(HttpContext context)
        {
            var config    = new Utility.SiteConfig();
            int CompanyID = 0;

            if (!string.IsNullOrEmpty(config.ServerSiteID))
            {
                CompanyID = int.Parse(config.ServerSiteID);
                return(CompanyID);
            }
            var defaultcompany = Company.GetCompanies().FirstOrDefault();

            if (defaultcompany != null)
            {
                return(defaultcompany.FromCompanyID);
            }
            return(0);
        }
コード例 #7
0
        public static bool doPostSmsMethod(string[] PhoneNumbers, List <string> paramList, string templateID, ref string sendResult, string sign = "")
        {
            try
            {
                var        config = new Utility.SiteConfig();
                Credential cred   = new Credential
                {
                    SecretId  = config.tencentSecretId,
                    SecretKey = config.tencentSecretKey
                };

                ClientProfile clientProfile = new ClientProfile();
                HttpProfile   httpProfile   = new HttpProfile();
                httpProfile.Endpoint      = ("sms.tencentcloudapi.com");
                clientProfile.HttpProfile = httpProfile;

                SmsClient      client = new SmsClient(cred, "", clientProfile);
                SendSmsRequest req    = new SendSmsRequest();
                PhoneNumbers = PhoneNumbers.Select(p =>
                {
                    return("+86" + p);
                }).ToArray();
                string strParams = "{\"PhoneNumberSet\":" + Utility.JsonConvert.SerializeObject(PhoneNumbers) + ",\"TemplateID\":\"" + templateID + "\",\"Sign\":\"" + sign + "\",\"TemplateParamSet\":" + Utility.JsonConvert.SerializeObject(paramList) + ",\"SmsSdkAppid\":\"" + config.tencentAppID + "\"}";
                req = SendSmsRequest.FromJsonString <SendSmsRequest>(strParams);
                SendSmsResponse resp = client.SendSmsSync(req);
                sendResult = Utility.JsonConvert.SerializeObject(resp);
                if (resp.SendStatusSet != null && resp.SendStatusSet.Length > 0 && resp.SendStatusSet[0].Code.ToLower().Equals("ok"))
                {
                    return(true);
                }
                sendResult = Utility.JsonConvert.SerializeObject(resp);
                Utility.LogHelper.WriteInfo("Utility.TencentSms.doPostSmsMethod", sendResult);
                return(false);
            }
            catch (Exception ex)
            {
                sendResult = ex.Message;
                LogHelper.WriteError("Utility.TencentSms", "doPostSmsMethod", ex);
                return(false);
            }
        }
コード例 #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (!string.IsNullOrEmpty(Request.QueryString["typeid"]))
         {
             int.TryParse(Request.QueryString["typeid"], out ServiceTypeID);
         }
         int BaoXiuServiceID     = new Utility.SiteConfig().BaoXiuServiceID;
         var typeList            = Foresight.DataAccess.ServiceType.GetServiceTypes().ToArray();
         var typeList2           = typeList.Where(p => p.ParentID == BaoXiuServiceID).ToArray();
         var BaoShiServiceIDList = new SiteConfig().BaoShiServiceIDList;
         if (BaoShiServiceIDList != null && BaoShiServiceIDList.Length > 0)
         {
             if (ServiceTypeID == 3)//报修
             {
                 typeList2 = typeList2.Where(p => !BaoShiServiceIDList.Contains(p.ID)).ToArray();
             }
             if (ServiceTypeID == 4)//报事
             {
                 typeList2 = typeList2.Where(p => BaoShiServiceIDList.Contains(p.ID)).ToArray();
             }
         }
         var typeItems2 = typeList2.Select(p =>
         {
             var item = new { ID = p.ID, Name = p.ServiceTypeName };
             return(item);
         }).ToList();
         typeItems2.Insert(0, new { ID = 0, Name = "全部" });
         typeItems2.Insert(0, new { ID = -1, Name = "不限" });
         this.hdServiceTypeName2.Value = Utility.JsonConvert.SerializeObject(typeItems2);
         var typeList2IDList = typeList2.Select(p => p.ID).ToArray();
         var typeList3       = typeList.Where(p => typeList2IDList.Contains(p.ParentID)).ToArray();
         var typeItems3      = typeList3.Select(p =>
         {
             var item = new { ID = p.ID, Name = p.ServiceTypeName, ParentID = p.ParentID };
             return(item);
         }).ToList();
         this.hdServiceTypeName3.Value = Utility.JsonConvert.SerializeObject(typeItems3);
     }
 }
コード例 #9
0
        /// <summary>
        /// 统计发送
        /// </summary>
        public static bool doPullSendStatus(DateTime StartTime, DateTime EndTime, ref int FeeCount, ref int RequestCount, ref int RequestSuccessCount)
        {
            try
            {
                var        config = new Utility.SiteConfig();
                Credential cred   = new Credential
                {
                    SecretId  = config.tencentSecretId,
                    SecretKey = config.tencentSecretKey
                };

                ClientProfile clientProfile = new ClientProfile();
                HttpProfile   httpProfile   = new HttpProfile();
                httpProfile.Endpoint      = ("sms.tencentcloudapi.com");
                clientProfile.HttpProfile = httpProfile;

                SmsClient client = new SmsClient(cred, "", clientProfile);
                SendStatusStatisticsRequest req = new SendStatusStatisticsRequest();
                string strParams = "{}";
                req = SendStatusStatisticsRequest.FromJsonString <SendStatusStatisticsRequest>(strParams);
                SendStatusStatisticsResponse resp = client.SendStatusStatisticsSync(req);
                if (resp.SendStatusStatistics != null)
                {
                    FeeCount            = (int)resp.SendStatusStatistics.FeeCount;
                    RequestCount        = (int)resp.SendStatusStatistics.RequestCount;
                    RequestSuccessCount = (int)resp.SendStatusStatistics.RequestSuccessCount;
                    return(true);
                }
                Utility.LogHelper.WriteInfo("Utility.TencentSms.doPullSendStatus", Utility.JsonConvert.SerializeObject(resp));
                return(false);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("Utility.TencentSms", "doPullSendStatus", ex);
                return(false);
            }
        }
コード例 #10
0
        private static string EncriptName(string Name)
        {
            var    config     = new Utility.SiteConfig();
            string EncriptURL = config.EncriptURL;

            if (!string.IsNullOrEmpty(EncriptURL) && EncriptURL.Equals("0"))
            {
                return(Name);
            }
            if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["DES"]))
            {
                string sKey = "saasyy20";
                using (DESCryptoServiceProvider des = new DESCryptoServiceProvider())
                {
                    byte[] inputByteArray = Encoding.UTF8.GetBytes(Name);
                    des.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
                    des.IV  = ASCIIEncoding.ASCII.GetBytes(sKey);
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    using (CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write))
                    {
                        cs.Write(inputByteArray, 0, inputByteArray.Length);
                        cs.FlushFinalBlock();
                        cs.Close();
                    }
                    string str = Convert.ToBase64String(ms.ToArray());
                    ms.Close();
                    return(str);
                }
            }
            else
            {
                System.Web.Security.FormsAuthenticationTicket ticket = new System.Web.Security.FormsAuthenticationTicket(1, Name, DateTime.Now, DateTime.Now.AddMinutes(10), true, string.Empty);
                string key = System.Web.Security.FormsAuthentication.Encrypt(ticket);
                return(key);
            }
        }
コード例 #11
0
        private static bool IsLocalSystem()
        {
            var config = new Utility.SiteConfig();

            return(Convert.ToBoolean(config.IsLocalSite));
        }
コード例 #12
0
        private void upgradeweixinsite(HttpContext context)
        {
            string     IDs    = context.Request["IDList"];
            List <int> IDList = new List <int>();

            if (!string.IsNullOrEmpty(IDs))
            {
                IDList = JsonConvert.DeserializeObject <List <int> >(IDs);
            }
            if (IDList.Count == 0)
            {
                WebUtil.WriteJson(context, new { status = false, error = "公司为空" });
                return;
            }
            HttpPostedFile postedFile = context.Request.Files[0];
            string         fileName   = postedFile.FileName;

            if (fileName == "" || fileName == null)
            {
                WebUtil.WriteJson(context, new { status = false, error = "请上传文件" });
                return;
            }
            string extension = System.IO.Path.GetExtension(fileName).ToLower();

            fileName = DateTime.Now.ToFileTime().ToString() + extension;
            string filepath = "/upload/";
            string rootPath = HttpContext.Current.Server.MapPath("~" + filepath);

            if (!System.IO.Directory.Exists(rootPath))
            {
                System.IO.Directory.CreateDirectory(rootPath);
            }
            string ZipPath = rootPath + fileName;

            postedFile.SaveAs(ZipPath);
            var    companys = Foresight.DataAccess.Company.GetAllActiveCompanyList().Where(p => IDList.Contains(p.CompanyID)).ToArray();
            var    config   = new Utility.SiteConfig();
            string SitePath = config.Wechat_SitePath;
            string SiteName = config.SiteName;

            foreach (var company in companys)
            {
                if (!company.BaseURL.Contains(config.SITE_URL))
                {
                    WebUtil.WriteJson(context, new { status = false, error = "功能不支持,请手动配置微信" });
                    return;
                }
                string NewFileName = company.BaseURL.Replace(config.SITE_URL, "");
                string VirName     = NewFileName;
                string Sub_VirName = "html";
                if (NewFileName.StartsWith("http://"))
                {
                    NewFileName = "saas";
                    VirName     = "html";
                    Sub_VirName = "";
                }
                int SiteNumber = int.Parse(config.SiteNumber);
                Utility.Tools.UnZipFile(ZipPath, SitePath, NewFileName);
                string my_sitepath = SitePath + NewFileName + @"\html";
                bool   sitestatus  = IISManager.CreateWebSite(SiteName, VirName, my_sitepath, false, 1, SiteNumber, "localhost", Sub_VirName);
            }
            WebUtil.WriteJson(context, new { status = true });
        }
コード例 #13
0
        private void upgrade_out_company_file(List <Foresight.DataAccess.Company> company_list, Foresight.DataAccess.SiteVersion site_version, out string error_sites, out List <Foresight.DataAccess.Company> company_list_out)
        {
            error_sites      = string.Empty;
            company_list_out = new List <Foresight.DataAccess.Company>();
            var    config       = new Utility.SiteConfig();
            string base_url     = config.SITE_URL;
            string SitePath     = config.SitePath;
            var    version_list = Foresight.DataAccess.SiteVersion.GetSiteVersions();
            int    VersionCode  = site_version.VersionCode;

            foreach (var company in company_list)
            {
                company.VersionCode = company.VersionCode > 0 ? company.VersionCode : 1;
                List <Utility.SiteVersionModel> site_version_model_list = new List <Utility.SiteVersionModel>();
                for (int i = company.VersionCode + 1; i <= VersionCode; i++)
                {
                    var current_version = version_list.FirstOrDefault(p => p.VersionCode == i);
                    if (current_version == null)
                    {
                        continue;
                    }
                    Utility.SiteVersionModel site_version_model = null;
                    string SqlPath = current_version.SqlPath;
                    if (!string.IsNullOrEmpty(SqlPath))
                    {
                        string extension = System.IO.Path.GetExtension(current_version.SqlPath).ToLower();
                        if (extension.ToLower().Contains("sql"))
                        {
                            if (site_version_model == null)
                            {
                                site_version_model             = new Utility.SiteVersionModel();
                                site_version_model.VersionCode = current_version.VersionCode;
                            }
                            site_version_model.SqlPath = WebUtil.GetContextPath() + SqlPath;
                        }
                    }
                    string FilePath = current_version.FilePath;
                    if (!string.IsNullOrEmpty(FilePath))
                    {
                        string extension = System.IO.Path.GetExtension(FilePath).ToLower();
                        if (extension.ToLower().Contains("zip"))
                        {
                            if (site_version_model == null)
                            {
                                site_version_model             = new Utility.SiteVersionModel();
                                site_version_model.VersionCode = current_version.VersionCode;
                            }
                            site_version_model.FilePath = WebUtil.GetContextPath() + FilePath;
                        }
                    }
                    if (site_version_model != null)
                    {
                        site_version_model_list.Add(site_version_model);
                    }
                }
                if (EncryptHelper.DoUpgradeSite(company, site_version_model_list, VersionCode, out error_sites))
                {
                    company_list_out.Add(company);
                }
            }
        }
コード例 #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ServiceID"></param>
        /// <param name="ErrorMsg"></param>
        /// <param name="title"></param>
        /// <param name="SendUserID"></param>
        /// <param name="SendUserName"></param>
        /// <param name="service"></param>
        /// <param name="AccpetUserType">1-通知接单人 2-通知处理人</param>
        /// <returns></returns>
        public static bool SendJpushMsgByServiceID(int ServiceID, out string ErrorMsg, string title = "", int SendUserID = 0, string SendUserName = "", Foresight.DataAccess.CustomerService service = null, List <int> ServiceAccpetManIDList = null, List <int> ServiceProcessManIDList = null, bool isReturnNotify = false)
        {
            ErrorMsg = "";
            var config = new Utility.SiteConfig();

            if (string.IsNullOrEmpty(config.JPushKey_User))
            {
                ErrorMsg = "推送未配置";
                return(false);
            }
            if (service == null)
            {
                service = Foresight.DataAccess.CustomerService.GetCustomerService(ServiceID);
            }
            if (service == null)
            {
                ErrorMsg = "ID不合法";
                return(false);
            }
            string result      = string.Empty;
            string result_push = string.Empty;
            string result_ios  = string.Empty;

            #region 派单人推送
            if (service.ServiceStatus == 10 || service.ServiceStatus == 3)
            {
                if (ServiceAccpetManIDList == null)
                {
                    ServiceAccpetManIDList = Foresight.DataAccess.CustomerService_Accpet.GetCustomerService_AccpetListByServiceID(ServiceID, new int[] { 0, 1 }, AccpetUserType: 1).Select(p => p.AccpetManID).ToList();
                }
                if (ServiceAccpetManIDList.Count > 0)//待派单
                {
                    var users = Foresight.DataAccess.User.GetPushUserListByIDListByIDList(ServiceAccpetManIDList);
                    if (users.Length > 0)
                    {
                        Dictionary <string, object> extras = new Dictionary <string, object>();
                        string pushMsg = string.Empty;
                        if (isReturnNotify)
                        {
                            pushMsg = "您有新工单需要重新派单,请尽快处理";
                        }
                        var extra_model = new Utility.JpushContent(service.ServiceStatus, Msg: pushMsg, Type: "customerservice");
                        extras["code"]     = extra_model.code;
                        extras["msg"]      = extra_model.msg;
                        extras["type"]     = extra_model.type;
                        extras["id"]       = service.ID;
                        extras["status"]   = service.ServiceStatus;
                        extras["isreturn"] = isReturnNotify;
                        var      users_android = users.Where(p => p.APPUserDeviceType.Equals("android")).ToArray();
                        var      users_ios     = users.Where(p => p.APPUserDeviceType.Equals("ios")).ToArray();
                        string[] android_cids  = new string[] { };
                        string[] ios_cids      = new string[] { };
                        if (users_android.Length > 0)
                        {
                            android_cids = users_android.Select(p => p.APPUserDeviceID).ToArray();
                        }
                        if (users_ios.Length > 0)
                        {
                            ios_cids = users_ios.Select(p => p.APPUserDeviceID).ToArray();
                        }
                        result_push = JPush.JpushAPI.PushMessage(title, extras, android_cids, ios_cids, extra_model.msg);
                        Foresight.DataAccess.JPushLog.Insert_JPushLog(android_cids, ios_cids, extras, result_push, 1, service.ID, true, title);
                    }
                }
            }
            #endregion
            #region 处理人推送
            if (service.ServiceStatus == 0)
            {
                if (ServiceProcessManIDList == null)
                {
                    ServiceProcessManIDList = Foresight.DataAccess.CustomerService_Accpet.GetCustomerService_AccpetListByServiceID(ServiceID, new int[] { 0, 1 }, AccpetUserType: 2).Select(p => p.AccpetManID).ToList();
                }
                if (ServiceProcessManIDList.Count > 0)//通知处理人
                {
                    var users = Foresight.DataAccess.User.GetPushUserListByIDListByIDList(ServiceProcessManIDList);
                    if (users.Length > 0)
                    {
                        Dictionary <string, object> extras = new Dictionary <string, object>();
                        var extra_model = new Utility.JpushContent(service.ServiceStatus, Type: "customerservice");
                        extras["code"]   = extra_model.code;
                        extras["msg"]    = extra_model.msg;
                        extras["type"]   = extra_model.type;
                        extras["id"]     = service.ID;
                        extras["status"] = service.ServiceStatus;
                        var      users_android = users.Where(p => p.APPUserDeviceType.Equals("android")).ToArray();
                        var      users_ios     = users.Where(p => p.APPUserDeviceType.Equals("ios")).ToArray();
                        string[] android_cids  = new string[] { };
                        string[] ios_cids      = new string[] { };
                        if (users_android.Length > 0)
                        {
                            android_cids = users_android.Select(p => p.APPUserDeviceID).ToArray();
                        }
                        if (users_ios.Length > 0)
                        {
                            ios_cids = users_ios.Select(p => p.APPUserDeviceID).ToArray();
                        }
                        result_push = JPush.JpushAPI.PushMessage(title, extras, android_cids, ios_cids, extra_model.msg);
                        Foresight.DataAccess.JPushLog.Insert_JPushLog(android_cids, ios_cids, extras, result_push, 1, service.ID, true, title);
                    }
                }
            }
            #endregion
            service.IsAPPSend     = true;
            service.SendUserID    = SendUserID;
            service.SendUserName  = SendUserName;
            service.APPSendTime   = DateTime.Now;
            service.APPSendResult = result_push;
            service.Save();
            return(true);
        }
コード例 #15
0
 private void savesite(HttpContext context)
 {
     try
     {
         var    config         = new Utility.SiteConfig();
         string VirName        = context.Request.Params["sitename"];
         int    CompanyID      = int.Parse(context.Request.Params["CompanyID"]);
         int    SiteNumber     = int.Parse(config.SiteNumber);
         string SiteName       = config.SiteName;
         string ZipPath        = config.ZipPath;
         string SitePath       = config.SitePath;
         int    ServerLocation = WebUtil.GetIntValue(context, "ServerLocation");
         int    VersionCode    = 1;
         int.TryParse(config.SysVersionCode, out VersionCode);
         var company = Foresight.DataAccess.Company.GetCompany(CompanyID);
         if (company == null)
         {
             WebUtil.WriteJsonError(context, ErrorCode.InvalideRequest, "公司已删除");
             return;
         }
         if (string.IsNullOrEmpty(VirName))
         {
             WebUtil.WriteJsonError(context, ErrorCode.InvalideRequest, "网址不能为空");
             return;
         }
         company.ServerLocation = ServerLocation;
         if (company.ServerLocation == 1)
         {
             if (!VirName.ToLower().StartsWith("http://") && !VirName.ToLower().StartsWith("https://"))
             {
                 WebUtil.WriteJsonError(context, ErrorCode.InvalideRequest, "网址输入不正确");
                 return;
             }
             company.BaseURL     = VirName;
             company.IsActive    = true;
             company.IsAdmin     = false;
             company.IsCustomer  = true;
             company.VersionCode = company.VersionCode > 0 ? company.VersionCode : VersionCode;
             company.Save();
             WebUtil.WriteJsonResult(context, "生成成功");
             return;
         }
         if (!string.IsNullOrEmpty(company.BaseURL))
         {
             WebUtil.WriteJsonError(context, ErrorCode.InvalideRequest, "网址已分配");
             return;
         }
         var URLList = Foresight.DataAccess.Company.GetCompanies().Select(p => p.BaseURL);
         if (URLList.Any(p => p.Contains(VirName)))
         {
             WebUtil.WriteJsonError(context, ErrorCode.InvalideRequest, "网站已存在");
             return;
         }
         string SiteURL = config.SITE_URL + VirName;
         string DBName  = "yy_" + VirName;
         try
         {
             Utility.Tools.UnZipFile(ZipPath, SitePath, VirName);
             bool sitestatus = IISManager.CreateWebSite(SiteName, VirName, SitePath + VirName, false, 1, SiteNumber, "localhost");
             //if (!sitestatus)
             //{
             //    WebUtil.WriteJsonError(context, ErrorCode.InvalideRequest, "网站已存在");
             //    return;
             //}
             string ConfigPath = SitePath + VirName + @"\Web.config";
             if (!System.IO.File.Exists(ConfigPath))
             {
                 ConfigPath = SitePath + @"Web.config";
             }
             if (System.IO.File.Exists(ConfigPath))
             {
                 Dictionary <string, object> dic = new Dictionary <string, object>();
                 dic["SITE_URL"]    = SiteURL;
                 dic["CompanyName"] = company.CompanyName;
                 dic["CopyRight"]   = DateTime.Now.Year.ToString() + " " + company.CompanyName;
                 dic["ConnString"]  = config.ConnString + ";database=" + DBName;
                 Utility.IISManager.UpdateConfigValue(ConfigPath, dic);
             }
         }
         catch (Exception)
         {
         }
         #region 生成数据库
         try
         {
             Utility.SQLHelper.CreateDataBase(DBName, CompanyID);
             company.BaseURL     = SiteURL;
             company.IsActive    = true;
             company.IsAdmin     = false;
             company.IsCustomer  = true;
             company.VersionCode = VersionCode;
             company.Save();
             string sqltext = @"insert into [" + DBName + "].[dbo].[Company]([CompanyName],[CompanyDesc],[PhoneNumber],[Address],[ChargePerson],[AddTime],[IsActive],[BaseURL],[VersionCode]) select [CompanyName],[CompanyDesc],[PhoneNumber],[Address],[ChargePerson],[AddTime],[IsActive],[BaseURL],[VersionCode] from [prosystem].[dbo].[Company] where CompanyID=" + company.CompanyID + ";";
             Utility.SQLHelper.ExecuteSql("master", sqltext);
             sqltext = @"insert into [" + DBName + "].[dbo].[User]([LoginName],[Password],[PhoneNumber],[Email],[HeadImg],[NickName],[RealName],[Gender],[Type],[CreateTime],[IsLocked],[LockTime]) select [LoginName],[Password],[PhoneNumber],[Email],[HeadImg],[NickName],[RealName],[Gender],[Type],[CreateTime],[IsLocked],[LockTime] from [prosystem].[dbo].[User] where UserID in (select UserID from [prosystem].[dbo].[UserCompany] where [CompanyID]=" + CompanyID + ");";
             Utility.SQLHelper.ExecuteSql("master", sqltext);
         }
         catch (Exception)
         {
         }
         #endregion
         WebUtil.WriteJsonResult(context, "生成成功");
     }
     catch (Exception ex)
     {
         WebUtil.WriteJsonError(context, ErrorCode.InvalideRequest, ex);
     }
 }
コード例 #16
0
        private void socketinit(HttpContext context)
        {
            var config = new Utility.SiteConfig();

            WebUtil.WriteJson(context, new { loginname = Web.WebUtil.GetUserLoginFullName(context) + Web.WebUtil.GetUser(context).LoginName, guid = HttpContext.Current.User.Identity.Name, url = config.SITE_URL, socketserver = config.SocketURL });
        }
コード例 #17
0
        private void GetProjectTree(HttpContext context)
        {
            int    CompanyID = WebUtil.GetIntValue(context, "CompanyID");
            int    ID        = WebUtil.GetIntValue(context, "ID");
            string Keywords  = context.Request.Params["Keywords"];
            int    RoleID    = WebUtil.GetIntValue(context, "RoleID");
            int    UserID    = WebUtil.GetIntValue(context, "UserID");

            ProjectTree[] list = ProjectTree.GetProjectTreeListByRoleIDAndUserID(ID, Keywords, RoleID, UserID, CompanyID: CompanyID).ToArray();
            List <Dictionary <string, object> > items = null;
            var dic = new Dictionary <string, object>();

            if (string.IsNullOrEmpty(Keywords))
            {
                items = list.Select(p =>
                {
                    dic             = p.ToJsonObject();
                    dic["type"]     = Utility.EnumModel.ProjectTreeTypeDefine.project.ToString();
                    dic["name"]     = p.Name;
                    dic["id"]       = p.ID;
                    dic["pId"]      = p.ParentID == 1 ? Utility.EnumModel.ProjectTreeTypeDefine.company.ToString() + "_" + p.CompanyID : p.ParentID.ToString();
                    dic["iconSkin"] = "Icon_" + p.IconID;
                    dic["open"]     = true;
                    dic["checked"]  = false;
                    if (RoleID > 0)
                    {
                        dic["checked"] = RoleID == p.RoleID;
                    }
                    if (UserID > 0)
                    {
                        dic["checked"] = UserID == p.UserID;
                    }
                    return(dic);
                }).ToList();
                if (CompanyID <= 0 && ID <= 0)
                {
                    var companyList     = Foresight.DataAccess.Company.GetCompanies().ToArray();
                    var companyRoleList = Foresight.DataAccess.UserCompany.GetUserCompanies().ToArray();
                    if (RoleID > 0)
                    {
                        companyRoleList = companyRoleList.Where(p => p.RoleID == RoleID).ToArray();
                    }
                    else
                    {
                        companyRoleList = companyRoleList.Where(p => p.UserID == UserID).ToArray();
                    }
                    var companyItems = companyList.Select(p =>
                    {
                        var myCompanyRole = companyRoleList.FirstOrDefault(q => q.CompanyID == p.CompanyID);
                        var type          = Utility.EnumModel.ProjectTreeTypeDefine.company.ToString();
                        dic                = new Dictionary <string, object>();
                        dic["ID"]          = p.CompanyID;
                        dic["ParentID"]    = 1;
                        dic["Name"]        = p.CompanyName;
                        dic["FullName"]    = p.CompanyName;
                        dic["isParent"]    = true;
                        dic["CompanyID"]   = p.CompanyID;
                        dic["id"]          = type + "_" + p.CompanyID;
                        dic["pId"]         = 1;
                        dic["name"]        = p.CompanyName;
                        dic["type"]        = Utility.EnumModel.ProjectTreeTypeDefine.company.ToString();
                        dic["iconSkin"]    = "Icon_0";
                        dic["open"]        = "true";
                        dic["isRoom"]      = false;
                        dic["IsLocked"]    = false;
                        dic["chkDisabled"] = false;
                        dic["checked"]     = myCompanyRole != null;
                        return(dic);
                    }).ToList();
                    items.AddRange(companyItems);
                    dic                = new Dictionary <string, object>();
                    dic["ID"]          = 1;
                    dic["ParentID"]    = 0;
                    dic["Name"]        = new Utility.SiteConfig().CompanyName;
                    dic["FullName"]    = string.Empty;
                    dic["isParent"]    = true;
                    dic["CompanyID"]   = 0;
                    dic["id"]          = 1;
                    dic["pId"]         = 0;
                    dic["name"]        = new Utility.SiteConfig().CompanyName;
                    dic["type"]        = Utility.EnumModel.ProjectTreeTypeDefine.company.ToString();
                    dic["iconSkin"]    = "Icon_0";
                    dic["open"]        = "true";
                    dic["isRoom"]      = false;
                    dic["IsLocked"]    = false;
                    dic["chkDisabled"] = false;
                    items.Add(dic);
                }
            }
            else
            {
                items = list.Select(p =>
                {
                    dic = p.ToJsonObject();
                    if (p.ID == 1)
                    {
                        var company = Company.GetCompany(CompanyID);
                        dic["name"] = company.CompanyName;
                    }
                    else
                    {
                        dic["name"] = p.FullName + p.Name;
                    }
                    dic["id"]       = p.ID;
                    dic["pId"]      = p.ParentID;
                    dic["iconSkin"] = "Icon_" + p.IconID;
                    dic["open"]     = true;
                    dic["checked"]  = false;
                    if (RoleID > 0)
                    {
                        dic["checked"] = RoleID == p.RoleID;
                    }
                    if (UserID > 0)
                    {
                        dic["checked"] = UserID == p.UserID;
                    }
                    return(dic);
                }).ToList();
            }
            WebUtil.WriteJson(context, items);
        }
コード例 #18
0
        private void savewxservice(HttpContext context)
        {
            int ProjectID = WebUtil.GetIntValue(context, "ProjectID");

            if (ProjectID <= 0)
            {
                WebUtil.WriteJsonError(context, ErrorCode.InvalideRequest, "请选择项目");
                return;
            }
            var service = new Foresight.DataAccess.CustomerService();

            service.AddTime         = DateTime.Now;
            service.AddMan          = context.Request.Params["AddMan"];
            service.AddUserID       = 0;
            service.IsSuggestion    = WebUtil.GetBoolValue(context, "IsSuggestion");
            service.ServiceStatus   = 3;
            service.ServiceFullName = context.Request["FullName"];
            service.ProjectID       = ProjectID;
            service.ServiceType1ID  = WebUtil.GetIntValue(context, "TypeID1");
            int TypeID2 = WebUtil.GetIntValue(context, "TypeID2");
            int TypeID3 = WebUtil.GetIntValue(context, "TypeID3");

            if (TypeID2 > 0)
            {
                service.ServiceType2ID = "[" + TypeID2 + "]";
            }
            if (TypeID3 > 0)
            {
                service.ServiceType3ID = "[" + TypeID3 + "]";
            }
            service.ProjectName     = context.Request["ProjectName"];
            service.ServiceFullName = service.ProjectName;
            service.AddUserName     = "******";
            service.StartTime       = DateTime.Now;//反应时间
            int    OrderNumberID = 0;
            string ServiceNumber = Foresight.DataAccess.CustomerService.GetLastestCustomerServiceNumber(Foresight.DataAccess.OrderTypeNameDefine.customerservice.ToString(), 0, out OrderNumberID);

            service.ServiceNumber      = ServiceNumber;
            service.OrderNumberID      = OrderNumberID;
            service.AddCustomerName    = context.Request["AddCustomerName"]; //反映人
            service.AddCallPhone       = context.Request["PhoneNo"];         //反映人联系电话
            service.ServiceContent     = context.Request["Content"];
            service.ServiceAppointTime = WebUtil.GetDateValue(context, "AppointTime");
            service.ServiceFrom        = Utility.EnumModel.WechatServiceFromDefine.weixin.ToString();
            List <Foresight.DataAccess.CustomerServiceAttach> attachlist = new List <Foresight.DataAccess.CustomerServiceAttach>();
            string FilePaths = context.Request["FilePaths"];
            List <Dictionary <string, object> > FilePathList = new List <Dictionary <string, object> >();

            if (!string.IsNullOrEmpty(FilePaths))
            {
                FilePathList = Utility.JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(FilePaths);
            }
            HttpFileCollection uploadFiles = context.Request.Files;

            foreach (var item in FilePathList)
            {
                Foresight.DataAccess.CustomerServiceAttach attach = new Foresight.DataAccess.CustomerServiceAttach();
                attach.FileOriName      = item["FileOriName"].ToString();
                attach.AttachedFilePath = item["FilePath"].ToString();
                attach.AddTime          = DateTime.Now;
                attachlist.Add(attach);
            }
            using (SqlHelper helper = new SqlHelper())
            {
                try
                {
                    helper.BeginTransaction();
                    service.Save(helper);
                    foreach (var item in attachlist)
                    {
                        item.ServiceID = service.ID;
                        item.Save(helper);
                    }
                    helper.Commit();
                }
                catch (Exception ex)
                {
                    Utility.LogHelper.WriteError("ServiceHandler", "命令: savewxservice", ex);
                    helper.Rollback();
                    WebUtil.WriteJsonError(context, ErrorCode.InvalideRequest, ex.Message);
                    return;
                }
            }
            if (!service.IsSuggestion)
            {
                string title = new Utility.SiteConfig().CompanyName;
                APPCode.SocketNotify.PushSocketNotifyAlert(EnumModel.SocketNotifyDefine.notifyservice, ID: service.ID);
            }
            else
            {
                string notify_msg = APPCode.SocketNotify.PushSocketNotifyAlert(EnumModel.SocketNotifyDefine.notifysuggestion, ID: service.ID);
            }
            WebUtil.WriteJsonResult(context, "Success");
        }
コード例 #19
0
        private void upgradecompany_file(List <Foresight.DataAccess.Company> company_list, Foresight.DataAccess.SiteVersion site_version, out string error_sql_sites, out string error_file_sites, out List <Foresight.DataAccess.Company> company_list_out)
        {
            error_sql_sites  = string.Empty;
            error_file_sites = string.Empty;
            company_list_out = new List <Foresight.DataAccess.Company>();
            var    config       = new Utility.SiteConfig();
            string base_url     = config.SITE_URL;
            string SitePath     = config.SitePath;
            var    version_list = Foresight.DataAccess.SiteVersion.GetSiteVersions().Where(p => p.VersionType.Equals("platform") || string.IsNullOrEmpty(p.VersionType)).OrderByDescending(p => p.VersionCode);

            foreach (var company in company_list)
            {
                if (!company.BaseURL.ToLower().StartsWith(base_url))
                {
                    continue;
                }
                string SiteName = company.BaseURL.Replace(base_url, "");
                company.VersionCode = company.VersionCode > 0 ? company.VersionCode : 1;
                string FilePath = string.Empty;
                for (int i = company.VersionCode + 1; i <= site_version.VersionCode; i++)
                {
                    var current_version = version_list.FirstOrDefault(p => p.VersionCode == i);
                    if (current_version == null)
                    {
                        continue;
                    }
                    string SqlPath = current_version.SqlPath;
                    if (!string.IsNullOrEmpty(SqlPath))
                    {
                        string extension = System.IO.Path.GetExtension(current_version.SqlPath).ToLower();
                        if (extension.ToLower().Contains("sql"))
                        {
                            try
                            {
                                string SQLFullPath  = HttpContext.Current.Server.MapPath("~" + SqlPath);
                                string DatabaseName = "yy_" + SiteName;
                                Utility.SQLHelper.ExecuteSQLFile(SQLFullPath, DatabaseName);
                                if (!company_list_out.Select(p => p.CompanyID).ToList().Contains(company.CompanyID))
                                {
                                    company_list_out.Add(company);
                                }
                            }
                            catch (Exception ex)
                            {
                                error_sql_sites += company.CompanyName + ",";
                                LogHelper.WriteError("更新数据库失败", company.CompanyName, ex);
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(current_version.FilePath))
                    {
                        FilePath = current_version.FilePath;
                    }
                }
                if (!string.IsNullOrEmpty(FilePath))
                {
                    string extension = System.IO.Path.GetExtension(FilePath).ToLower();
                    if (extension.ToLower().Contains("zip"))
                    {
                        try
                        {
                            string FileFullPath = HttpContext.Current.Server.MapPath("~" + FilePath);
                            string SiteFullPath = SitePath + SiteName;
                            Utility.Tools.UnZipFile(FileFullPath, SiteFullPath, "");
                            if (!company_list_out.Select(p => p.CompanyID).ToList().Contains(company.CompanyID))
                            {
                                company_list_out.Add(company);
                            }
                        }
                        catch (Exception ex)
                        {
                            error_file_sites += company.CompanyName + ",";
                            LogHelper.WriteError("更新系统文件失败", company.CompanyName, ex);
                        }
                    }
                }
            }
        }