コード例 #1
0
        public override void OnSetFederatedOrganizationIdentifier(FederationTrust federationTrust, SmtpDomain accountNamespace)
        {
            string    text                 = accountNamespace.ToString();
            string    wkgDomain            = FederatedOrganizationId.AddHybridConfigurationWellKnownSubDomain(text);
            AppIdInfo appIdInfo            = null;
            ManageDelegation2Client client = this.GetManageDelegation(wkgDomain);

            try
            {
                appIdInfo = client.CreateAppId(wkgDomain);
            }
            catch (LiveDomainServicesException ex)
            {
                if (ex.DomainError != null && ex.DomainError.Value == DomainError.ProofOfOwnershipNotValid)
                {
                    throw new DomainProofOwnershipException(Strings.ErrorManageDelegation2ProofDomainOwnership, ex);
                }
                throw new ProvisioningFederatedExchangeException(ex.LocalizedString, ex);
            }
            if (string.IsNullOrEmpty(federationTrust.ApplicationIdentifier))
            {
                if (appIdInfo == null || string.IsNullOrEmpty(appIdInfo.AppId))
                {
                    throw new LiveDomainServicesException(Strings.ErrorLiveDomainServicesUnexpectedResult(Strings.ErrorInvalidApplicationId));
                }
                base.WriteVerbose(Strings.NewFederationTrustSuccessAppId(FederationTrust.PartnerSTSType.LiveId.ToString(), appIdInfo.AppId));
                federationTrust.ApplicationIdentifier = appIdInfo.AppId.Trim();
            }
            base.ReserveDomain(wkgDomain, federationTrust.ApplicationIdentifier, client, Strings.ErrorManageDelegation2ProofDomainOwnership, () => LiveFederationProvision2.GetDomainStateFromDomainInfo(client.GetDomainInfo(federationTrust.ApplicationIdentifier, wkgDomain)));
            using (ManageDelegation2Client manageDelegation = this.GetManageDelegation(text))
            {
                manageDelegation.AddUri(appIdInfo.AppId, text);
            }
        }
コード例 #2
0
        /// <summary>
        /// 获取Api请求地址
        /// </summary>
        /// <returns></returns>
        public string GetReqUrl()
        {
            string    urlFormat = "https://api.weixin.qq.com/cgi-bin/token?grant_type={0}&appid={1}&secret={2}";
            AppIdInfo info      = AppIdInfo == null?GetDefaultAppIdInfo() : AppIdInfo;

            string url = string.Format(urlFormat, "client_credential", info.AppID, info.AppSecret);

            return(url);
        }
コード例 #3
0
        /// <summary>
        /// 获取Api请求地址
        /// </summary>
        /// <returns></returns>
        public string GetReqUrl()
        {
            string    urlFormat = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code";
            AppIdInfo info      = AppIdInfo == null?GetDefaultAppIdInfo() : AppIdInfo;

            string url = string.Format(urlFormat, info.AppID, info.AppSecret, this.Code);

            return(url);
        }
コード例 #4
0
        public AppIdInfo CreateAppId(string rawBase64Certificate)
        {
            AppIdInfo appIdInfo = null;

            base.ExecuteAndHandleError(string.Format("CreateAppId(certificate='{0}',properties=[])", rawBase64Certificate), delegate
            {
                appIdInfo = this.manageDelegation.CreateAppId(rawBase64Certificate, new Property[0]);
            });
            return(appIdInfo);
        }
コード例 #5
0
ファイル: RequestBase.cs プロジェクト: sd009896/CustomerMall
        /// <summary>
        /// 获取默认AppInfo信息
        /// </summary>
        /// <returns></returns>
        protected AppIdInfo GetDefaultAppIdInfo()
        {
            AppIdInfo info = new AppIdInfo()
            {
                AppID  = "1",
                MchUID = "2",
            };

            return(info);
        }
コード例 #6
0
        public AppIdInfo CreateAppId(string uri)
        {
            AppIdInfo appIdInfo = null;

            base.ExecuteAndHandleError(string.Format("CreateAppId(uri='{0}',properties=[0])", uri), delegate
            {
                appIdInfo = this.manageDelegation.CreateAppId(uri, new Property[0]);
            });
            return(appIdInfo);
        }
コード例 #7
0
        /* 测试账号申请地址
         *  http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login
         */

        /// <summary>
        /// 获取默认AppInfo信息
        /// </summary>
        /// <returns></returns>
        protected AppIdInfo GetDefaultAppIdInfo()
        {
            AppIdInfo info = new AppIdInfo()
            {
                AppID     = "1",
                AppSecret = "2",
                CallBack  = "3"
            };

            return(info);
        }
コード例 #8
0
ファイル: RequestBase.cs プロジェクト: liuyang1302/WX_V1
        /* 测试账号申请地址
         *  http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login
         */

        /// <summary>
        /// 获取默认AppInfo信息
        /// </summary>
        /// <returns></returns>
        protected AppIdInfo GetDefaultAppIdInfo()
        {
            AppIdInfo info = new AppIdInfo()
            {
                AppID     = WxResource.AppId,
                AppSecret = WxResource.AppSecret,
                CallBack  = "3"
            };

            return(info);
        }
コード例 #9
0
        public override void OnNewFederationTrust(FederationTrust federationTrust)
        {
            X509Certificate x509Certificate      = FederationCertificate.LoadCertificateWithPrivateKey(federationTrust.OrgPrivCertificate, base.WriteVerbose);
            string          rawBase64Certificate = Convert.ToBase64String(x509Certificate.GetRawCertData());
            AppIdInfo       appIdInfo            = null;

            using (ManageDelegation1Client manageDelegation = this.GetManageDelegation())
            {
                appIdInfo = manageDelegation.CreateAppId(rawBase64Certificate);
            }
            if (appIdInfo == null || string.IsNullOrEmpty(appIdInfo.AppId))
            {
                throw new LiveDomainServicesException(Strings.ErrorLiveDomainServicesUnexpectedResult(Strings.ErrorInvalidApplicationId));
            }
            federationTrust.ApplicationIdentifier       = appIdInfo.AppId.Trim();
            federationTrust.AdministratorProvisioningId = appIdInfo.AdminKey.Trim();
            base.WriteVerbose(Strings.NewFederationTrustSuccessAppId(FederationTrust.PartnerSTSType.LiveId.ToString(), federationTrust.ApplicationIdentifier));
        }
コード例 #10
0
        public AutomaticDestination(byte[] rawBytes, string sourceFile)
        {
            if (rawBytes.Length == 0)
            {
                throw new Exception("Empty file");
            }

            SourceFile = sourceFile;

            var appid = Path.GetFileName(sourceFile).Split('.').FirstOrDefault();

            if (appid != null)
            {
                var aid = new AppIdInfo(appid);
                AppId = aid;
            }
            else
            {
                AppId = new AppIdInfo("Unable to determine AppId");
            }

            _oleContainer = new OleCfFile(rawBytes, sourceFile);

            Directory = _oleContainer.Directory;

            var destList = _oleContainer.Directory.SingleOrDefault(t => t.DirectoryName.ToLowerInvariant() == "destlist");

            if (destList != null && destList.DirectorySize > 0)
            {
                var destBytes = _oleContainer.GetPayloadForDirectory(destList);

                DestList = new DestList(destBytes);
            }


            DestListEntries = new List <AutoDestList>();

            if (DestList != null)
            {
                DestListCount       = DestList.Header.NumberOfEntries;
                DestListVersion     = DestList.Header.Version;
                LastUsedEntryNumber = DestList.Header.LastEntryNumber;

                foreach (var entry in DestList.Entries)
                {
                    var dirItem =
                        _oleContainer.Directory.SingleOrDefault(
                            t =>
                            string.Equals(t.DirectoryName, entry.EntryNumber.ToString("X"),
                                          StringComparison.InvariantCultureIgnoreCase));

                    if (dirItem != null)
                    {
                        var sfn = $"{sourceFile}_Directory name_{dirItem.DirectoryName:X}";

                        var p = _oleContainer.GetPayloadForDirectory(dirItem);

                        var dlnk = new LnkFile(p, sfn);

                        var dle = new AutoDestList(entry, dlnk);

                        DestListEntries.Add(dle);
                    }
                    else
                    {
                        var dleNull = new AutoDestList(entry, null);

                        DestListEntries.Add(dleNull);
                    }
                }
            }
        }
コード例 #11
0
        void AnalyzeJumplist()
        {
            schedulerStorage.Appointments.Clear();
            string[] jumpListFilesAutomatic =
                Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
                                   "\\Microsoft\\Windows\\Recent\\AutomaticDestinations\\",
                                   "*.automaticDestinations-ms");



            DataTable jumpListDataTable = new DataTable();

            jumpListDataTable.Columns.AddRange(new DataColumn[]
            {
                new DataColumn("Source File"),
                new DataColumn("App Id"),
                new DataColumn("File Path"),
                new DataColumn("Created Time"),
                new DataColumn("Modified Time"),
                new DataColumn("Accessed Time"),
                new DataColumn("Size"),
                new DataColumn("Entry Id"),
                new DataColumn("Machine Name"),
                new DataColumn("MAC Address"),
                new DataColumn("Pinned Status")
            });

            foreach (var autofiles in jumpListFilesAutomatic)
            {
                var autoDestFile = JumpList.JumpList.LoadAutoJumplist(autofiles);

                if (autoDestFile.DestListEntries.Count > 0)
                {
                    foreach (var automaticfileEntry in autoDestFile.DestListEntries)
                    {
                        Appointment n = new AppointmentInstance();
                        n.Subject = automaticfileEntry.Path;
                        n.Start   = DateTimeOffset.Parse(automaticfileEntry.LastModified.ToString(), null).DateTime;
                        n.End     = DateTimeOffset.Parse(automaticfileEntry.LastModified.ToString(), null).DateTime;

                        string description = "File Path: " + automaticfileEntry.Path + "\nModified On: " +
                                             automaticfileEntry.LastModified + "\nCreated On: " +
                                             automaticfileEntry.CreatedOn + "\nFile Size: " +
                                             automaticfileEntry.Lnk.Header.FileSize;

                        n.Description = description;
                        schedulerStorage.Appointments.Items.Add(n);


                        string    sourceFile = autoDestFile.SourceFile;
                        AppIdInfo appId      = autoDestFile.AppId;

                        int entryId = automaticfileEntry.EntryNumber;

                        string entryPath = automaticfileEntry.Path;

                        DateTimeOffset targetCreatedOn      = automaticfileEntry.Lnk.Header.TargetCreationDate.DateTime;
                        DateTimeOffset targetModifiedOn     = automaticfileEntry.Lnk.Header.TargetModificationDate.DateTime;
                        DateTimeOffset targetLastAccessedOn =
                            automaticfileEntry.Lnk.Header.TargetLastAccessedDate.DateTime;

                        uint fileSize = automaticfileEntry.Lnk.Header.FileSize;

                        string machineName  = automaticfileEntry.Hostname;
                        string macAdd       = automaticfileEntry.MacAddress;
                        bool   pinnedStatus = automaticfileEntry.Pinned;

                        jumpListDataTable.Rows.Add(sourceFile, appId, entryPath, targetCreatedOn, targetModifiedOn,
                                                   targetLastAccessedOn, fileSize, entryId, machineName, macAdd, pinnedStatus);
                    }
                }
            }


            string[] jumpListFilesCustom = Directory.GetFiles(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
                "\\Microsoft\\Windows\\Recent\\CustomDestinations\\   ", "*.customDestinations-ms");

            foreach (var custfiles in jumpListFilesCustom)
            {
                try
                {
                    var custDestFiles = JumpList.JumpList.LoadCustomJumplist(custfiles);

                    string    cSourceFile = custDestFiles.SourceFile;
                    AppIdInfo cAppId      = custDestFiles.AppId;
                    int       cEntryId    = custDestFiles.Entries.Count;



                    // Console.WriteLine("List Count " + custDestFiles.Entries.Count);
                    foreach (var custDestEntry in custDestFiles.Entries)
                    {
                        foreach (var c in custDestEntry.LnkFiles)
                        {
                            string         cLocalPath       = c.LocalPath;
                            DateTimeOffset cTargetCreatedOn = c.Header.TargetCreationDate.DateTime;

                            DateTimeOffset cTargetModifiedOn = c.Header.TargetModificationDate.DateTime;

                            DateTimeOffset cTargetAccessedOn = c.Header.TargetLastAccessedDate.DateTime;

                            uint cFileSize = c.Header.FileSize;

                            Appointment n = new AppointmentInstance();
                            n.Subject = cSourceFile;
                            n.Start   = DateTimeOffset.Parse(cTargetModifiedOn.ToString(), null).DateTime;
                            n.End     = DateTimeOffset.Parse(cTargetModifiedOn.ToString(), null).DateTime;


                            string description = "File Path: " + cLocalPath + "\nModified On: " +
                                                 cTargetModifiedOn + "\nCreated On: " +
                                                 cTargetCreatedOn + "\nFile Size: " +
                                                 cFileSize;

                            n.Description = description;
                            schedulerStorage.Appointments.Items.Add(n);

                            jumpListDataTable.Rows.Add(cSourceFile, cAppId, cLocalPath, cTargetCreatedOn,
                                                       cTargetModifiedOn,
                                                       cTargetAccessedOn, cFileSize, cEntryId, null, null, null);
                            //dataGridView1.Rows.Add(cSourceFile, cAppId, cLocalPath, cTargetCreatedOn, cTargetModifiedOn, cTargetAccessedOn, cFileSize, cEntryId, null, null, "True");
                        }
                    }
                    //  Console.WriteLine(custDestFiles.);

                    //Console.WriteLine(customDestFiles);
                }
                catch (Exception ee)
                {
                    continue;
                }
            }

            gridControl1.DataSource = jumpListDataTable;
        }
コード例 #12
0
ファイル: Service1.cs プロジェクト: gxlbang/yoga
        /// <summary>
        /// 后台抄表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ReadingHandleTimerTimerEvent(object sender, System.Timers.ElapsedEventArgs e)
        {
            ReadingHandleTimer.Stop();
            var taskList = database.FindList <Am_BackstageTask>(" and Status=0");

            foreach (var item in taskList)
            {
                var result = GetResult(item.Number);
                var root   = JsonHelper.JonsToList <Root>(result);
                if (root != null)
                {
                    if (root.Count == 1)
                    {
                        var example = root[0];
                        item.TaskMark = "[主动查询]" + result;
                        if (example.status == "SUCCESS")
                        {
                            item.Status    = 1;
                            item.StatusStr = "成功";
                            if (example.data != null)
                            {
                                item.Remark = example.data[0].dsp;
                            }

                            item.OverTime = DateTime.Parse(example.resolve_time);
                        }
                        else if (example.status == "FAIL")
                        {
                            item.Status    = 2;
                            item.StatusStr = "失败";
                            item.OverTime  = DateTime.Parse(example.resolve_time);
                        }
                        else if (example.status == "NOTSUPPORT")
                        {
                            item.Status    = 2;
                            item.StatusStr = "不支持此功能";
                            item.OverTime  = DateTime.Parse(example.resolve_time);
                        }
                        else if (example.status == "TIMEOUT")
                        {
                            item.Status    = 2;
                            item.StatusStr = "超时";
                            item.OverTime  = DateTime.Parse(example.resolve_time);
                        }
                        else if (example.status == "ACCEPTED")
                        {
                            item.StatusStr = "请求已接受";
                        }
                        else if (example.status == "QUEUE")
                        {
                            item.StatusStr = "调度状态";
                        }
                        else if (example.status == "PROCESSING")
                        {
                            item.StatusStr = "正在处理中";
                        }
                        database.Update <Am_BackstageTask>(item);
                    }
                }
                if (item.Status > 0 && item.Status < 4)
                {
                    var log = DbHelper.GetLog(item.Number);
                    if (log != null)
                    {
                        log.Result = item.StatusStr;
                        DbHelper.UpdateLog(log);
                    }
                    if (root.Count == 1)
                    {
                        var example = root[0];
                        if (example.data != null && example.data.Count > 0)
                        {
                            int type = example.data[0].type;
                            List <DbParameter> par = new List <DbParameter>();
                            par.Add(DbFactory.CreateDbParameter("@Number", item.AmmeterNumber));
                            var ammeter = database.FindEntityByWhere <Am_Ammeter>(" and Number =@Number ", par.ToArray());
                            //查询余额
                            if (type == 22)
                            {
                                if (ammeter != null && ammeter.Number != null)
                                {
                                    ammeter.CurrMoney = double.Parse(example.data[0].value[0].ToString());
                                    ammeter.CM_Time   = DateTime.Parse(example.resolve_time);
                                    ammeter.Acount_Id = null;
                                    if (ammeter.CurrMoney < ammeter.FirstAlarm && ammeter.IsLowerWarning == 1)
                                    {
                                        ammeter.IsLowerWarning = 2;
                                        //发微信通知
                                        IMpClient             mpClient = new MpClient();
                                        AccessTokenGetRequest request  = new AccessTokenGetRequest()
                                        {
                                            AppIdInfo = new AppIdInfo()
                                            {
                                                AppID = ConfigHelper.AppSettings("WEPAY_WEB_APPID"), AppSecret = ConfigHelper.AppSettings("WEPAY_WEb_AppSecret")
                                            }
                                        };
                                        AccessTokenGetResponse response = mpClient.Execute(request);
                                        if (response.IsError)
                                        {
                                            this.WriteLog(response.ErrInfo.ErrMsg);
                                        }
                                        Weixin.Mp.Sdk.Domain.First first = new First();
                                        first.color = "#000000";
                                        first.value = ammeter.U_Name + ",您" + ammeter.Room + "号房电费不足";
                                        Weixin.Mp.Sdk.Domain.Keynote1 keynote1 = new Keynote1();
                                        keynote1.color = "#0000ff";
                                        keynote1.value = ammeter.CurrMoney.Value.ToString("0.00");
                                        Weixin.Mp.Sdk.Domain.Keynote2 keynote2 = new Keynote2();
                                        keynote2.color = "#0000ff";
                                        keynote2.value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                                        Weixin.Mp.Sdk.Domain.Remark remark = new Remark();
                                        remark.color = "#464646";
                                        remark.value = "请及时充值,以免影响您正常用电!";
                                        Weixin.Mp.Sdk.Domain.Data data = new Data();
                                        data.first    = first;
                                        data.keynote1 = keynote1;
                                        data.keynote2 = keynote2;
                                        data.remark   = remark;
                                        Weixin.Mp.Sdk.Domain.Miniprogram miniprogram = new Miniprogram();
                                        miniprogram.appid    = "";
                                        miniprogram.pagepath = "";
                                        Weixin.Mp.Sdk.Domain.TemplateMessage templateMessage = new TemplateMessage();
                                        templateMessage.data        = data;
                                        templateMessage.miniprogram = miniprogram;
                                        templateMessage.template_id = "AaRgB6rFU6Z3kUbagN16Mp7DbT293yI8nuE96Xvoxdk";
                                        var usermodel = database.FindEntity <Ho_PartnerUser>(ammeter.U_Number);
                                        templateMessage.touser = usermodel.OpenId;
                                        templateMessage.url    = "http://am.zst0771.com/Personal/AmmeterRecharge?number=" + ammeter.Number;
                                        string postData = templateMessage.ToJsonString1(); /*JsonHelper.ToJson(templateMessage);*/

                                        AppIdInfo app = new AppIdInfo()
                                        {
                                            AppID     = ConfigHelper.AppSettings("WEPAY_WEB_APPID"),
                                            AppSecret = ConfigHelper.AppSettings("WEPAY_WEb_AppSecret"),
                                            CallBack  = ""
                                        };
                                        SendTemplateMessageRequest req = new SendTemplateMessageRequest()
                                        {
                                            AccessToken = response.AccessToken.AccessToken,
                                            SendData    = postData,
                                            AppIdInfo   = app
                                        };
                                        SendTemplateMessageResponse res = mpClient.Execute(req);
                                        if (res.IsError)
                                        {
                                            this.WriteLog(res.ErrInfo.ErrMsg);
                                        }
                                    }
                                    database.Update(ammeter);
                                }
                            }
                            //查询电量
                            if (type == 20)
                            {
                                if (ammeter != null && ammeter.Number != null)
                                {
                                    ammeter.CurrPower = decimal.Parse(example.data[0].value[0].ToString()).ToString("0.00");
                                    ammeter.CP_Time   = DateTime.Parse(example.resolve_time);
                                    DbHelper.UpdateAmmeter(ammeter);
                                }
                            }
                        }
                    }
                }
            }
            ReadingHandleTimer.Start();
        }
コード例 #13
0
ファイル: Service1.cs プロジェクト: gxlbang/yoga
        /// <summary>
        /// 账单推送
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BillSendTimerdEvent(object sender, System.Timers.ElapsedEventArgs e)
        {
            BillSendTimer.Stop();
            var config = database.FindEntityByWhere <Fx_WebConfig>("");

            if (config != null && config.SendBillDate.Value > 0)
            {
                var time = DateTime.Now.AddDays(config.SendBillDate.Value);
                List <DbParameter> par = new List <DbParameter>();
                par.Add(DbFactory.CreateDbParameter("@time", time));
                par.Add(DbFactory.CreateDbParameter("@Status", "0"));

                var billList = database.FindList <Am_Bill>("  and  BeginTime<=@time and Status=@Status ", par.ToArray());
                foreach (var item in billList)
                {
                    item.Status    = 1;
                    item.StatusStr = "未支付";
                    item.SendTime  = DateTime.Now;
                    if (database.Update <Am_Bill>(item) > 0)
                    {
                        //账单推送
                        IMpClient             mpClient = new MpClient();
                        AccessTokenGetRequest request  = new AccessTokenGetRequest()
                        {
                            AppIdInfo = new AppIdInfo()
                            {
                                AppID = ConfigHelper.AppSettings("WEPAY_WEB_APPID"), AppSecret = ConfigHelper.AppSettings("WEPAY_WEb_AppSecret")
                            }
                        };
                        AccessTokenGetResponse response = mpClient.Execute(request);
                        if (response.IsError)
                        {
                            continue;
                        }
                        Weixin.Mp.Sdk.Domain.First first = new First();
                        first.color = "#000000";
                        first.value = item.T_U_Name + ",您本月的账单已生成";
                        Weixin.Mp.Sdk.Domain.Keynote1 keynote1 = new Keynote1();
                        keynote1.color = "#0000ff";
                        keynote1.value = item.Address + " " + item.Cell + "单元" + item.Floor + "楼" + item.Room + "号";
                        Weixin.Mp.Sdk.Domain.Keynote2 keynote2 = new Keynote2();
                        keynote2.color = "#0000ff";
                        keynote2.value = item.BeginTime.Value.ToString("yyyy-MM-dd") + "至" + item.EndTime.Value.ToString("yyyy-MM-dd");
                        Weixin.Mp.Sdk.Domain.Keynote3 keynote3 = new Keynote3();
                        keynote3.color = "#0000ff";
                        keynote3.value = item.Money.Value.ToString("0.00");
                        //Weixin.Mp.Sdk.Domain.Keynote4 keynote4 = new Keynote4();
                        //keynote4.color = "#0000ff";
                        //keynote4.value = model.s_Reception + "  " + model.s_ReMobile;
                        Weixin.Mp.Sdk.Domain.Remark remark = new Remark();
                        remark.color = "#464646";
                        remark.value = "请在" + config.SendBillDate.Value.ToString() + "天之内在线支付账单!";
                        Weixin.Mp.Sdk.Domain.Data data = new Data();
                        data.first    = first;
                        data.keynote1 = keynote1;
                        data.keynote2 = keynote2;
                        data.keynote3 = keynote3;
                        //data.keynote4 = keynote4;
                        data.remark = remark;
                        Weixin.Mp.Sdk.Domain.Miniprogram miniprogram = new Miniprogram();
                        miniprogram.appid    = "";
                        miniprogram.pagepath = "";
                        Weixin.Mp.Sdk.Domain.TemplateMessage templateMessage = new TemplateMessage();
                        templateMessage.data        = data;
                        templateMessage.miniprogram = miniprogram;
                        templateMessage.template_id = "d0NDpmuQ7BjtlxPurNTr9N1GlATOAQ98S8vrmgAijH8";
                        var usermodel = database.FindEntity <Ho_PartnerUser>(item.T_U_Number);
                        templateMessage.touser = usermodel.OpenId;
                        templateMessage.url    = "http://am.zst0771.com/Personal/NewBillDetails?Number=" + item.Number;
                        string postData = templateMessage.ToJsonString1(); /*JsonHelper.ToJson(templateMessage);*/

                        AppIdInfo app = new AppIdInfo()
                        {
                            AppID     = ConfigHelper.AppSettings("WEPAY_WEB_APPID"),
                            AppSecret = ConfigHelper.AppSettings("WEPAY_WEb_AppSecret"),
                            CallBack  = ""
                        };
                        SendTemplateMessageRequest req = new SendTemplateMessageRequest()
                        {
                            AccessToken = response.AccessToken.AccessToken,
                            SendData    = postData,
                            AppIdInfo   = app
                        };
                        SendTemplateMessageResponse res = mpClient.Execute(req);
                        if (res.IsError)
                        {
                            continue;
                        }
                    }
                }
            }
            BillSendTimer.Start();
        }
コード例 #14
0
        public CustomDestination(byte[] rawBytes, string sourceFile)
        {
            if (rawBytes.Length == 0)
            {
                throw new Exception("Empty file");
            }

            SourceFile = sourceFile;

            var appid = Path.GetFileName(sourceFile).Split('.').FirstOrDefault();

            if (appid != null)
            {
                var aid = new AppIdInfo(appid);
                AppId = aid;
            }
            else
            {
                AppId = new AppIdInfo("Unable to determine AppId");
            }

            if (rawBytes.Length <= 24)
            {
                throw new Exception("Empty custom destinations jump list");
            }

            var footerSig = BitConverter.ToInt32(footerBytes, 0);
            var fileSig   = BitConverter.ToInt32(rawBytes, rawBytes.Length - 4);

            if (footerSig != fileSig)
            {
                throw new Exception("Invalid signature (footer missing)");
            }

            Entries = new List <Entry>();

            var index = 0;

            //first, check for footer offsets. some files have more than one

            var footerOffsets = new List <int>();

            while (index < rawBytes.Length)
            {
                var lo = ByteSearch(rawBytes, footerBytes, index);

                if (lo == -1)
                {
                    break;
                }

                footerOffsets.Add(lo);

                index = lo + footerBytes.Length; //add length so we do not hit on it again
            }

            var byteChunks = new List <byte[]>();

            var absOffsets = new List <int>();

            var chunkStart = 0;

            foreach (var footerOffset in footerOffsets)
            {
                var chunkSize = footerOffset - chunkStart + 4;
                var bytes     = new byte[chunkSize];

                Buffer.BlockCopy(rawBytes, chunkStart, bytes, 0, bytes.Length);

                absOffsets.Add(chunkStart);

                byteChunks.Add(bytes);

                chunkStart += chunkSize;
            }

            var counter = 0;

            foreach (var byteChunk in byteChunks)
            {
                if (byteChunk.Length > 30)
                {
                    var e = new Entry(byteChunk, absOffsets[counter]);

                    Entries.Add(e);
                    counter += 1;
                }
            }
        }
コード例 #15
0
        public ActionResult SubmitUserForm(string KeyValue, string Number, Ho_SetSubscribe model, string BuildFormJson)
        {
            IDatabase     database    = DataFactory.Database();
            DbTransaction isOpenTrans = database.BeginTrans();

            try
            {
                //获取订单信息-订单和接单安排分离
                var oldModel = database.FindEntity <Ho_MySubscribe>(Number);
                if (oldModel == null)
                {
                    return(Content(new JsonMessage {
                        Success = false, Code = "-1", Message = "预约不存在"
                    }.ToString()));
                }
                string Message = KeyValue == "" ? "新增成功。" : "编辑成功。";
                model.s_StatuStr   = model.s_Status == 0 ? "正常" : "做废";
                model.ReUserNumber = ManageProvider.Provider.Current().UserId;
                model.ReUser       = ManageProvider.Provider.Current().Account;
                if (!string.IsNullOrEmpty(KeyValue))
                {
                    model.Modify(KeyValue);
                    var IsOk = database.Update(model, isOpenTrans);
                    //更新订单状态为已安排
                    if (IsOk > 0 && model.s_Status == 0)
                    {
                        oldModel.Status    = 1;
                        oldModel.StatusStr = "接待中";
                        oldModel.Modify(oldModel.Number);
                        database.Update(oldModel, isOpenTrans);
                    }
                    Base_SysLogBll.Instance.WriteLog(KeyValue, OperationType.Update, IsOk > 0 ? "成功" : "失败", "预约接待安排更改");
                }
                else //新建
                {
                    model.MS_Number = oldModel.Number;
                    model.Create();
                    var IsOk = database.Insert(model, isOpenTrans);
                    //更新订单状态为已安排
                    if (IsOk > 0 && model.s_Status == 0)
                    {
                        oldModel.Status    = 1;
                        oldModel.StatusStr = "接待中";
                        oldModel.Modify(oldModel.Number);
                        database.Update(oldModel, isOpenTrans);
                    }
                    Base_SysLogBll.Instance.WriteLog(KeyValue, OperationType.Update, IsOk > 0 ? "成功" : "失败", "预约接待安排增加");
                }
                database.Commit();
                //发送微信通知
                IMpClient             mpClient = new MpClient();
                AccessTokenGetRequest request  = new AccessTokenGetRequest()
                {
                    AppIdInfo = new AppIdInfo()
                    {
                        AppID = ConfigHelper.AppSettings("AppID"), AppSecret = ConfigHelper.AppSettings("AppSecret")
                    }
                };
                AccessTokenGetResponse response = mpClient.Execute(request);
                if (response.IsError)
                {
                    Message += ":微信消息发送不成功-" + response.ErrInfo;
                    return(Content(new JsonMessage {
                        Success = true, Code = "1", Message = Message
                    }.ToString()));
                }
                Weixin.Mp.Sdk.Domain.First first = new First();
                first.color = "#000000";
                first.value = "您预约的看房已安排";
                Weixin.Mp.Sdk.Domain.Keynote1 keynote1 = new Keynote1();
                keynote1.color = "#0000ff";
                keynote1.value = model.s_MYTime;
                Weixin.Mp.Sdk.Domain.Keynote2 keynote2 = new Keynote2();
                keynote2.color = "#0000ff";
                keynote2.value = model.s_Address;
                Weixin.Mp.Sdk.Domain.Keynote3 keynote3 = new Keynote3();
                keynote3.color = "#0000ff";
                keynote3.value = oldModel.HName;
                Weixin.Mp.Sdk.Domain.Keynote4 keynote4 = new Keynote4();
                keynote4.color = "#0000ff";
                keynote4.value = model.s_Reception + "  " + model.s_ReMobile;
                Weixin.Mp.Sdk.Domain.Remark remark = new Remark();
                remark.color = "#464646";
                remark.value = "您有任何疑问随时联系ta";
                Weixin.Mp.Sdk.Domain.Data data = new Data();
                data.first    = first;
                data.keynote1 = keynote1;
                data.keynote2 = keynote2;
                data.keynote3 = keynote3;
                data.keynote4 = keynote4;
                data.remark   = remark;
                Weixin.Mp.Sdk.Domain.Miniprogram miniprogram = new Miniprogram();
                miniprogram.appid    = "";
                miniprogram.pagepath = "";
                Weixin.Mp.Sdk.Domain.TemplateMessage templateMessage = new TemplateMessage();
                templateMessage.data        = data;
                templateMessage.miniprogram = miniprogram;
                templateMessage.template_id = "nak4v_a9vwzdL9QMWv-Fl3ommOdN7kEORQ1X2BRJrCo";
                var usermodel = database.FindEntity <Ho_PartnerUser>(oldModel.UNumber);
                templateMessage.touser = usermodel.OpenId;
                templateMessage.url    = "http://house.pthl600.com/Ui/Industry?Number=" + oldModel.MHNumber;
                string postData = templateMessage.ToJsonString(); /*JsonHelper.ToJson(templateMessage);*/

                AppIdInfo app = new AppIdInfo()
                {
                    AppID     = ConfigHelper.AppSettings("AppID"),
                    AppSecret = ConfigHelper.AppSettings("AppSecret"),
                    CallBack  = ""
                };
                SendTemplateMessageRequest req = new SendTemplateMessageRequest()
                {
                    AccessToken = response.AccessToken.AccessToken,
                    SendData    = postData,
                    AppIdInfo   = app
                };
                SendTemplateMessageResponse res = mpClient.Execute(req);
                if (res.IsError)
                {
                    Message += ":微信消息发送失败-" + response.ErrInfo;
                    return(Content(new JsonMessage {
                        Success = true, Code = "1", Message = Message
                    }.ToString()));
                }
                return(Content(new JsonMessage {
                    Success = true, Code = "1", Message = Message
                }.ToString()));
            }
            catch (Exception ex)
            {
                database.Rollback();
                return(Content(new JsonMessage {
                    Success = false, Code = "-1", Message = "操作失败:" + ex.Message
                }.ToString()));
            }
        }