示例#1
0
        /// <summary>
        /// 本地服务器-保存集群当前配置
        /// </summary>
        private void button_Cluster_SaveIni_Click(object sender, RoutedEventArgs e)
        {
            int    indexLocal = listBox_LocalServer_ClusterFile.SelectedIndex;
            string nameLocal  = ComboBox_LocalServer_SavesFolder.SelectedItem?.ToString();

            if (tabItem_LocalServer.IsSelected)
            {
                if (indexLocal == -1)
                {
                    return;
                }

                ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Local[indexLocal].ClusterSetting);
                SavesManager.SetClusterInfo(nameLocal, m_ClusterInfo_Local[indexLocal]);
            }

            SftpClient client     = ServersManager.GetExistSftp(m_ServerConnect, UI.Location, UI.Username, UI.Password);
            int        indexCloud = listBox_CloudServer_ClusterFile.SelectedIndex;
            string     nameCloud  = ComboBox_CloudServer_SavesFolder.SelectedItem?.ToString();

            if (tabItem_CloudServer.IsSelected)
            {
                if (indexCloud == -1)
                {
                    return;
                }
                if (client == null)
                {
                    return;
                }

                ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Cloud[indexCloud].ClusterSetting);
                SavesManager.SetClusterInfo(nameCloud, m_ClusterInfo_Cloud[indexCloud], client);
            }
        }
示例#2
0
        /// <summary>
        /// 本地服务器-开启当前服务器集群
        /// </summary>
        private void button_LocalServer_StartCluster_Click(object sender, RoutedEventArgs e)
        {
            int indexLocalFile = listBox_LocalServer_ClusterFile.SelectedIndex;
            int indexLocalPath = dataGrid_LocalServer_ServersPath.SelectedIndex;

            if (indexLocalFile == -1 || indexLocalPath == -1)
            {
                return;
            }

            //保存当前选中的集群配置
            ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Local[indexLocalFile].ClusterSetting);
            SavesManager.SetClusterInfo(ComboBox_LocalServer_SavesFolder.SelectedItem?.ToString(), m_ClusterInfo_Local[indexLocalFile]);

            string confdir = ComboBox_LocalServer_SavesFolder.SelectedItem.ToString();
            string cluster = listBox_LocalServer_ClusterFile.SelectedItem.ToString();
            string exefile = (dataGrid_LocalServer_ServersPath.SelectedItem as DataRowView)[2].ToString();
            bool   isShell = (bool)radioButton_LocalServer_OpenType_1.IsChecked;

            //依次开启集群服务器
            foreach (var server in m_ClusterInfo_Local[indexLocalFile].ClusterServers)
            {
                string shard = server.Setting.Shard_Master ? "Master" : "Caves";

                string parameter = ServersManager.CreatParameter(confdir, cluster, shard);
                CreatNewProcess(exefile, parameter, isShell, server.Session);
            }
        }
示例#3
0
        public ActionResult SetState(string ids, short state)
        {
            var sId  = ids.Split(',').Select(o => int.Parse(o));
            var list = MembersService.FindList(o => sId.Contains(o.Id));

            #region 操作日志状态记录
            var _oList = new List <Members>();
            foreach (var item in list)
            {
                var _member = new Members();
                ExtendHelper.CopyProperty <Members>(_member, item);
                _oList.Add(_member);
            }
            #endregion

            list.ForEach(o => { o.Status = state; });
            var re = MembersService.Update(list);
            #region 操作日志
            if (re.Successed)
            {
                for (int i = 0; i < list.Count(); i++)
                {
                    var msg = Sys.LogEngine.CompareModelToLog <Members>(Sys.LogModule.会员管理, list[i], _oList[i]);
                    new Sys.LogEngine().WriteUpdate(msg, Sys.LogModule.会员管理);
                }
            }
            #endregion
            return(new JsonNetResult(re));
        }
        public static DiskGroupLockResult ExtendDynamicVolume(List <DynamicDisk> diskGroup, DynamicVolume volume, long numberOfAdditionalExtentSectors)
        {
            if (volume is StripedVolume)
            {
                numberOfAdditionalExtentSectors -= numberOfAdditionalExtentSectors % ((StripedVolume)volume).SectorsPerStripe;
            }
            if (volume is Raid5Volume)
            {
                numberOfAdditionalExtentSectors -= numberOfAdditionalExtentSectors % ((Raid5Volume)volume).SectorsPerStripe;
            }

            DiskGroupLockResult result = DiskGroupHelper.LockDiskGroup(diskGroup);

            if (result != DiskGroupLockResult.Success)
            {
                return(result);
            }

            DiskGroupDatabase database = DiskGroupDatabase.ReadFromDisks(diskGroup, volume.DiskGroupGuid);

            ExtendHelper.ExtendDynamicVolume((DynamicVolume)volume, numberOfAdditionalExtentSectors, database);

            DiskGroupHelper.UnlockDiskGroup(diskGroup);

            return(DiskGroupLockResult.Success);
        }
        /// <summary>
        /// 三点坐标过滤法  第2个点 (到1的距离+到3的距离)如果大于xx 陪 (1到3的距离) 则过滤
        /// </summary>
        public static bool Filter3Point(List <Location> listp, out Location filterLocation)
        {
            filterLocation = null; //过滤点
            double xx     = 2.5;   //十分钟异常参数
            double xxl    = 3;     //30分钟异常参数
            bool   isFilt = false;

            if (listp != null && listp.Count >= 5 && listp[1].LocationType != 2)
            {
                double times = Math.Abs((listp[0].GpsTime - listp[2].GpsTime).TotalSeconds);//3点内的时间间隔

                bool isMove = false;
                #region 是否在运动中前进 前四个点形成的钜形 高度小于一定值,证明在运动中
                double qq  = 300;                                                                           //距离300米以上,计算
                double xh  = 0.25;                                                                          //合法高度参数
                double d25 = PositionUtil.Distance(listp[1].Lat, listp[1].Lng, listp[4].Lat, listp[4].Lng); //2和5的距离

                double d23 = PositionUtil.Distance(listp[1].Lat, listp[1].Lng, listp[2].Lat, listp[2].Lng); //2和3的距离
                double d35 = PositionUtil.Distance(listp[2].Lat, listp[2].Lng, listp[4].Lat, listp[4].Lng); //3和5的距离
                double h3  = ExtendHelper.TriangleHeiht(d25, d23, d35);                                     //点3 的高

                double d24 = PositionUtil.Distance(listp[1].Lat, listp[1].Lng, listp[3].Lat, listp[3].Lng); //2和4的距离
                double d45 = PositionUtil.Distance(listp[3].Lat, listp[3].Lng, listp[4].Lat, listp[4].Lng); //4和5的距离
                double h4  = ExtendHelper.TriangleHeiht(d25, d24, d45);                                     //点4 的高

                if (d25 > qq && h3 < (d25 * xh) && h4 < (d25 * xh))
                {
                    isMove = true;
                }
                #endregion

                if (!isMove && times < 1800)//三十分钟以内
                {
                    double c  = PositionUtil.Distance(listp[0].Lat, listp[0].Lng, listp[2].Lat, listp[2].Lng);
                    double c1 = PositionUtil.Distance(listp[0].Lat, listp[0].Lng, listp[1].Lat, listp[1].Lng);
                    double c2 = PositionUtil.Distance(listp[1].Lat, listp[1].Lng, listp[2].Lat, listp[2].Lng);

                    if (times < 600)
                    {
                        if ((c1 + c2) > c * xx)//距离大于 xx陪过滤
                        {
                            isFilt = true;
                        }
                    }
                    else if (times < 1830)
                    {
                        if ((c1 + c2) > c * xxl)//距离大于 xxl陪过滤
                        {
                            isFilt = true;
                        }
                    }
                    if (isFilt)
                    {
                        filterLocation = listp[1];
                    }
                }
            }
            return(isFilt);
        }
        /// <summary>
        /// 更新集群下所有服务器信息
        /// </summary>
        /// <param name="clusterInfo">当前选定的集群信息</param>
        /// <param name="bindData">界面绑定的集群</param>
        private void RefreshServersData(ClusterInfo clusterInfo, ref UserInterfaceData bindData)
        {
            //将当前选定的集群信息赋值给界面绑定的类实例
            ExtendHelper.CopyAllProperties(clusterInfo.ClusterSetting, bindData);

            //更新当前选定的集群服务器DataGrid信息
            bindData.ClusterServersTable.Clear();
            ExtendHelper.CopyAllProperties(clusterInfo, bindData);
        }
        private void ExtendVolumeForm_Load(object sender, EventArgs e)
        {
            long numberOfExtentBytesAvailable = ExtendHelper.GetMaximumSizeToExtendVolume(m_volume);
            long numberOfMBAvailable          = numberOfExtentBytesAvailable / 1024 / 1024;

            numericAdditionalSize.Maximum = numberOfMBAvailable;
            numericAdditionalSize.Value   = numberOfMBAvailable;
            btnOK.Enabled = (numberOfMBAvailable > 0);
        }
        /// <summary>
        /// 更改会员卡状态
        /// </summary>
        /// <param name="state"></param>
        /// <param name="ids"></param>
        /// <returns></returns>
        public OpResult UpdateMemberCardState(short state, string ids)
        {
            try
            {
                var cards = CurrentRepository.Entities.Where(o => o.CompanyId == CommonService.CompanyId && ("," + ids + ",").Contains("," + o.Id + ","));
                //cards.Each(o => o.State = state);
                var message  = new StringBuilder();
                var stateStr = string.Empty;
                switch (state)
                {
                case 1:    //0:未激活;1:正常;2 已挂失;3:已作废;4 已退卡
                    stateStr = "成功激活会员卡【{0}】!";
                    break;

                case 2:    //
                    stateStr = "会员卡【{0}】已挂失!";
                    break;

                case 3:    //
                    stateStr = "会员卡【{0}】已作废!";
                    break;

                case 4:    //
                    stateStr = "会员卡【{0}】已退卡!";
                    break;
                }
                var _msg = new StringBuilder();
                foreach (var item in cards)
                {
                    var o = new MembershipCard();
                    ExtendHelper.CopyProperty <MembershipCard>(o, item);
                    item.State = state;
                    message.Append(string.Format(stateStr, item.CardSN));
                    _msg.Append(Pharos.Sys.LogEngine.CompareModelToLog <MembershipCard>(Sys.LogModule.会员管理, item, o));
                }
                #region 操作日志
                new Pharos.Sys.LogEngine().WriteUpdate(_msg.ToString(), Sys.LogModule.会员管理);
                #endregion
                CurrentRepository.Update(new MembershipCard());
                return(new OpResult()
                {
                    Successed = true, Message = message.ToString()
                });
            }
            catch (Exception e)
            {
                Log.WriteError(e);

                throw;
            }
        }
        public ActionResult Save(ProductCategory obj)
        {
            var re = new OpResult();

            obj.CompanyId = CommonService.CompanyId;
            if (ProductCategoryService.IsExist(o => o.CompanyId == obj.CompanyId && o.CategoryPSN == obj.CategoryPSN && o.Title == obj.Title && o.Id != obj.Id))
            {
                re.Message = "已存在该名称";
            }
            else if (obj.Id == 0)
            {
                if (obj.CategoryPSN > 0 && ProductService.IsExist(o => o.CompanyId == obj.CompanyId && o.CategorySN == obj.CategoryPSN))
                {
                    re.Message = "该分类存在商品,不允许创建!";
                    return(Content(re.ToJson()));
                }
                var max = ProductCategoryService.MaxSn;
                obj.CategorySN   = max;
                obj.Grade        = GetGrade;
                obj.CategoryCode = ProductCategoryService.MaxCode(obj.CategoryPSN);
                re = ProductCategoryService.Add(obj);
                #region 操作日志
                var msg = LogEngine.CompareModelToLog <ProductCategory>(LogModule.种类管理, obj);
                new LogEngine().WriteInsert(msg, LogModule.种类管理);
                #endregion
            }
            else
            {
                var supp = ProductCategoryService.FindById(obj.Id);
                obj.ToCopyProperty(supp);
                //supp.Grade = GetGrade;
                var oProCate = new ProductCategory();
                ExtendHelper.CopyProperty <ProductCategory>(oProCate, supp);
                re = ProductCategoryService.Update(supp);
                #region 操作日志
                var msg = LogEngine.CompareModelToLog <ProductCategory>(LogModule.种类管理, supp, oProCate);
                new LogEngine().WriteUpdate(msg, LogModule.种类管理);
                #endregion
            }
            if (re.Successed)
            {
                var stores = string.Join(",", WarehouseService.GetList().Select(o => o.StoreId));
                Pharos.Infrastructure.Data.Redis.RedisManager.Publish("SyncDatabase", new Pharos.ObjectModels.DTOs.DatabaseChanged()
                {
                    CompanyId = CommonService.CompanyId, StoreId = stores, Target = "ProductCategory"
                });
            }
            return(Content(re.ToJson()));
        }
示例#10
0
        /// <summary>
        /// 保存服务器当前配置
        /// </summary>
        private void button_Server_SaveIni_Click(object sender, RoutedEventArgs e)
        {
            int indexLocalServer_ClusterFile = listBox_LocalServer_ClusterFile.SelectedIndex;

            string nameSave    = ComboBox_LocalServer_SavesFolder.SelectedItem?.ToString();
            string nameCluster = listBox_LocalServer_ClusterFile.SelectedItem?.ToString();


            ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Local[indexLocalServer_ClusterFile]);

            for (int i = 0; i < m_ClusterInfo_Local[indexLocalServer_ClusterFile].ClusterServers.Count; i++)
            {
                SavesManager.SetServerInfo(nameSave, nameCluster, m_ClusterInfo_Local[indexLocalServer_ClusterFile].ClusterServers[i]);
            }
        }
        public static DiskGroupLockResult ExtendPartition(Partition volume, long numberOfAdditionalExtentSectors)
        {
            if (volume.Disk is PhysicalDisk)
            {
                if (Environment.OSVersion.Version.Major >= 6)
                {
                    bool isReadOnly;
                    bool isOnline = ((PhysicalDisk)volume.Disk).GetOnlineStatus(out isReadOnly);
                    if (!isOnline || isReadOnly)
                    {
                        return(DiskGroupLockResult.OneOrMoreDisksAreOfflineOrReadonly);
                    }
                }

                LockStatus status = LockHelper.LockBasicDiskAndVolumesOrNone(((PhysicalDisk)volume.Disk));
                if (status == LockStatus.CannotLockDisk)
                {
                    return(DiskGroupLockResult.CannotLockDisk);
                }
                else if (status == LockStatus.CannotLockVolume)
                {
                    return(DiskGroupLockResult.CannotLockVolume);
                }

                if (Environment.OSVersion.Version.Major >= 6)
                {
                    bool success = ((PhysicalDisk)volume.Disk).SetOnlineStatus(false);
                    if (!success)
                    {
                        return(DiskGroupLockResult.CannotTakeDiskOffline);
                    }
                }
            }

            ExtendHelper.ExtendPartition(volume, numberOfAdditionalExtentSectors);

            if (volume.Disk is PhysicalDisk)
            {
                if (Environment.OSVersion.Version.Major >= 6)
                {
                    bool success = ((PhysicalDisk)volume.Disk).SetOnlineStatus(true);
                }
                LockHelper.UnlockBasicDiskAndVolumes((PhysicalDisk)volume.Disk);
                ((PhysicalDisk)volume.Disk).UpdateProperties();
            }

            return(DiskGroupLockResult.Success);
        }
示例#12
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="login"></param>
        /// <returns></returns>
        public dynamic Login(UserLoginViewModel login)
        {
            var singleUser = GetSingleByWhere <dynamic>(t => t.Username == login.Username, t => new { t.Id, t.Password, t.Salt }).Data;

            if (singleUser == null)
            {
                return(new BusinessResponse(false, "该账号还未注册", "该账号还未注册"));
            }

            var inputPassword = ExtendHelper.MD5(login.Password + singleUser.Salt);

            if (inputPassword != singleUser.Password)
            {
                return(new BusinessResponse(false, "密码不正确", "密码不正确"));
            }

            return(new BusinessResponse <dynamic>(new { singleUser.Id }));
        }
示例#13
0
        public ActionResult setState_Editor(string id, short state)
        {
            var obj    = ContractBLL.FindById(id);
            var _oData = new Contract();

            ExtendHelper.CopyProperty <Contract>(_oData, obj);
            obj.State = state;
            var re = ContractBLL.Update(obj);

            #region 操作日志
            if (re.Successed)
            {
                var msg = LogEngine.CompareModelToLog <Contract>(LogModule.合同管理, obj, _oData);
                new LogEngine().WriteUpdate(msg, LogModule.合同管理);
            }
            #endregion
            return(new JsonNetResult(re));
        }
示例#14
0
        private void button_CloudServer_StartCluster_Click(object sender, RoutedEventArgs e)
        {
            SftpClient client         = ServersManager.GetExistSftp(m_ServerConnect, UI.Location, UI.Username, UI.Password);
            string     nameCloud      = ComboBox_CloudServer_SavesFolder.SelectedItem?.ToString();
            int        indexCloud     = listBox_CloudServer_ClusterFile.SelectedIndex;
            int        indexCloudFile = listBox_CloudServer_ClusterFile.SelectedIndex;

            if (client == null)
            {
                return;
            }

            ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Cloud[indexCloud].ClusterSetting);
            SavesManager.SetClusterInfo(nameCloud, m_ClusterInfo_Cloud[indexCloud], client);

            string confdir = ComboBox_CloudServer_SavesFolder.SelectedItem.ToString();
            string cluster = listBox_CloudServer_ClusterFile.SelectedItem.ToString();
            string exefile = (dataGrid_CloudServer_ServersPath.SelectedItem as DataRowView)[2].ToString();
            string exepath = exefile.Replace("/dontstarve_dedicated_server_nullrenderer", "");

            List <string> screenList = ServersManager.GetExistScreens(UI.Location, UI.Username, UI.Password);

            foreach (var server in m_ClusterInfo_Cloud[indexCloudFile].ClusterServers)
            {
                string shard = server.Setting.Shard_Master ? "Master" : "Caves";

                string parameter = ServersManager.CreatParameter(confdir, cluster, shard);

                string command    = string.Empty;
                string screenName = cluster + "_" + server.Folder;

                if (screenList.Contains(screenName))
                {
                    command = $"screen -xr {screenName}";
                }
                else
                {
                    command += $"cd {exepath}\r";
                    command += $"screen -S {screenName} {"./dontstarve_dedicated_server_nullrenderer"} {parameter}";
                }

                CreatNewScreens(UI.Location, UI.Username, UI.Password, command);
            }
        }
示例#15
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <returns></returns>
        public dynamic Register(UserLoginViewModel register)
        {
            if (AnyByWhere(t => t.Username == register.Username).Data)
            {
                return(new BusinessResponse(false, "该账号已注册", "该账号已注册"));
            }

            var userInfo = new UserInfo()
            {
                Username = register.Username,
                Mobile   = register.Username
            };

            userInfo.Salt     = ExtendHelper.MD5(Guid.NewGuid().ToString("N").Substring(1, 5));
            userInfo.Password = ExtendHelper.MD5(register.Password + userInfo.Salt);

            context.UserInfo.Add(userInfo);

            context.SaveChangesAsync();

            return(new BusinessResponse());
        }
示例#16
0
        public ActionResult AddContract(Logic.Entity.Contract obj)
        {
            var re = new OpResult();

            var relativePath = "";
            var files        = new List <Attachment>();
            var path         = Sys.SysConstPool.SaveAttachPath(ref relativePath);

            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];
                if (file.ContentLength <= 0)
                {
                    continue;
                }
                var    filename = CommonRules.GUID + Path.GetExtension(file.FileName);
                string fullname = path + filename;
                file.SaveAs(fullname);
                files.Add(new Attachment()
                {
                    SourceClassify = 1,
                    Title          = Path.GetFileName(file.FileName),
                    Size           = file.ContentLength / 1024,
                    SaveUrl        = relativePath + filename
                });
            }
            var jia      = new Logic.Entity.ContractBoth();
            var yi       = new Logic.Entity.ContractBoth();
            var compname = Request["CompanyName"];

            if (!compname.IsNullOrEmpty())
            {
                var comps = compname.Split(',');
                jia.CompanyName = comps[0];
                yi.CompanyName  = comps[1];
            }
            var representative = Request["Representative"];

            if (!representative.IsNullOrEmpty())
            {
                var repr = representative.Split(',');
                jia.Representative = repr[0];
                yi.Representative  = repr[1];
            }
            var tel = Request["Tel"];

            if (!tel.IsNullOrEmpty())
            {
                var te = tel.Split(',');
                jia.Tel = te[0];
                yi.Tel  = te[1];
            }
            var fax = Request["Fax"];

            if (!fax.IsNullOrEmpty())
            {
                var fa = fax.Split(',');
                jia.Fax = fa[0];
                yi.Fax  = fa[1];
            }
            var taxnumber = Request["TaxNumber"];//甲方是TaxNumber,乙方是PayNumber,除此之外其余的项甲乙方都相同

            if (!taxnumber.IsNullOrEmpty())
            {
                jia.TaxNumber = taxnumber;
            }
            var paynumber = Request["PayNumber"];//乙方是PayNumber

            if (!paynumber.IsNullOrEmpty())
            {
                yi.PayNumber = paynumber;
            }
            var url = Request["Url"];

            if (!url.IsNullOrEmpty())
            {
                var ur = url.Split(',');
                jia.Url = ur[0];
                yi.Url  = ur[1];
            }
            var address = Request["Address"];

            if (!address.IsNullOrEmpty())
            {
                var addr = address.Split(',');
                jia.Address = addr[0];
                yi.Address  = addr[1];
            }
            var postcode = Request["PostCode"];

            if (!postcode.IsNullOrEmpty())
            {
                var pcode = postcode.Split(',');
                jia.PostCode = pcode[0];
                yi.PostCode  = pcode[1];
            }
            var bankname = Request["BankName"];

            if (!bankname.IsNullOrEmpty())
            {
                var bname = bankname.Split(',');
                jia.BankName = bname[0];
                yi.BankName  = bname[1];
            }

            var bankaccount = Request["BankAccount"];

            if (!bankaccount.IsNullOrEmpty())
            {
                var baccount = bankaccount.Split(',');
                jia.BankAccount = baccount[0];
                yi.BankAccount  = baccount[1];
            }
            obj.CompanyId = CommonService.CompanyId;
            if (string.IsNullOrEmpty(obj.Id))
            {
                obj.ContractBoths = new List <Logic.Entity.ContractBoth>();

                obj.Id         = CommonRules.GUID;
                obj.CreateDT   = DateTime.Now;
                obj.CreateUID  = Sys.CurrentUser.UID;
                obj.ContractSN = ContractBLL.CreateContractSN();

                obj.Attachments = files;
                jia.Signatory   = (int)(ContractSignatory.甲方);
                yi.Signatory    = (int)(ContractSignatory.乙方);
                obj.ContractBoths.Add(jia);
                obj.ContractBoths.Add(yi);

                //var existContractSN = ContractBLL.Find(o => o.ContractSN == obj.ContractSN);
                //if (existContractSN != null)
                //{
                //    re.Message = "该合同编号已存在!";
                //}
                //else
                //{
                //    re = ContractBLL.Add(obj);
                //}
                re = ContractBLL.Add(obj);
                #region 操作日志
                var msg = LogEngine.CompareModelToLog <Contract>(LogModule.合同管理, obj);
                new LogEngine().WriteInsert(msg, LogModule.合同管理);
                #endregion
            }
            else
            {
                var contract = ContractBLL.GetObj(obj.Id);
                //var oldContractSN = contract.ContractSN;
                Contract _contract = new Contract();
                ExtendHelper.CopyProperty <Contract>(_contract, contract);
                obj.Version = contract.Version;
                obj.PId     = contract.PId;

                obj.ToCopyProperty(contract);

                contract.Attachments.AddRange(files);

                var detailId = Request["detailId"];
                if (!detailId.IsNullOrEmpty())
                {
                    var detailIds = detailId.Split(',');
                    var jiaId     = int.Parse(detailIds[0]);
                    var yiId      = int.Parse(detailIds[1]);
                    jia.Id        = jiaId;
                    yi.Id         = yiId;
                    jia.Signatory = 1;
                    yi.Signatory  = 2;
                    var jiares = contract.ContractBoths.FirstOrDefault(o => o.Id == jiaId);
                    var yires  = contract.ContractBoths.FirstOrDefault(o => o.Id == yiId);
                    //jia.ContractId = jiares.ContractId;
                    //yi.ContractId = yires.ContractId;
                    jia.ToCopyProperty(jiares);
                    yi.ToCopyProperty(yires);
                }
                //var existContractSN = ContractBLL.FindList(o => o.ContractSN == contract.ContractSN);
                //if (existContractSN.Count > 0 && oldContractSN != obj.ContractSN)
                //{
                //    re.Message = "该合同编号已存在!";
                //}
                //else
                //{
                //    re = ContractBLL.Update(contract);
                //}
                re = ContractBLL.Update(contract);
                #region 操作日志
                var msg = LogEngine.CompareModelToLog <Contract>(LogModule.合同管理, obj, _contract);
                new LogEngine().WriteUpdate(msg, LogModule.合同管理);
                #endregion
            }
            return(Content(re.ToJson()));
        }
示例#17
0
        public static OpResult SaveOrUpdate(Supplier obj)
        {
            var re = new OpResult();

            if (!obj.MasterAccount.IsNullOrEmpty() && SupplierService.IsExist(o => o.Id != obj.Id && o.MasterAccount == obj.MasterAccount && o.BusinessType == 2 && o.CompanyId == CommonService.CompanyId))
            {
                re.Message = "该账号已存在,请重新填写!";
            }
            else if (!obj.Title.IsNullOrEmpty() && SupplierService.IsExist(o => o.Id != obj.Id && o.Title == obj.Title && o.BusinessType == 2 && o.CompanyId == CommonService.CompanyId))
            {
                re.Message = "该简称已存在,请重新填写!";
            }
            else if (!obj.FullTitle.IsNullOrEmpty() && SupplierService.IsExist(o => o.Id != obj.Id && o.FullTitle == obj.FullTitle && o.BusinessType == 2 && o.CompanyId == CommonService.CompanyId))
            {
                re.Message = "该全称已存在,请重新填写!";
            }
            else if (obj.Id.IsNullOrEmpty())
            {
                obj.Id           = Logic.CommonRules.GUID;
                obj.BusinessType = 2;
                obj.CompanyId    = CommonService.CompanyId;
                re = SupplierService.Add(obj);
                #region 操作日志
                try
                {
                    LogEngine logEngine = new LogEngine();
                    var       logMsg    = LogEngine.CompareModelToLog <Supplier>(LogModule.批发商, obj);
                    logEngine.WriteInsert(logMsg, LogModule.批发商);
                }
                catch
                {
                }
                #endregion
            }
            else
            {
                var      supp   = SupplierService.FindById(obj.Id);
                Supplier _oInfo = new Supplier();
                if (supp != null)
                {
                    ExtendHelper.CopyProperty <Supplier>(_oInfo, supp);
                }
                var exc = new List <string>();
                if (obj.MasterPwd.IsNullOrEmpty())
                {
                    exc.Add("MasterPwd");
                }
                exc.Add("CompanyId");
                obj.BusinessType = supp.BusinessType;
                obj.ToCopyProperty(supp, exc);
                re = SupplierService.Update(supp);
                #region 操作日志
                try
                {
                    LogEngine logEngine = new LogEngine();
                    var       logMsg    = LogEngine.CompareModelToLog <Supplier>(LogModule.批发商, obj, _oInfo);
                    logEngine.WriteUpdate(logMsg, LogModule.批发商);
                }
                catch
                {
                }
                #endregion
            }
            return(re);
        }
示例#18
0
        /// <summary>
        /// Extend the partition and TrueCrypt volume
        /// </summary>
        public static TrueCryptResizeStatus ExtendVolume(Disk disk, byte[] password, long additionalNumberOfSectors)
        {
            Partition       partition = VolumeSelectionHelper.GetLastPartition(disk);
            TrueCryptVolume volume;

            try
            {
                volume = new TrueCryptVolume(partition, password);
            }
            catch (InvalidDataException)
            {
                return(TrueCryptResizeStatus.InvalidDisk);
            }
            catch (NotSupportedException)
            {
                return(TrueCryptResizeStatus.UnsupportedFormatVersion);
            }

            if (volume.IsHiddenVolume)
            {
                return(TrueCryptResizeStatus.HiddenVolume);
            }

            long availableBytes;

            if (partition is MBRPartition || partition is GPTPartition)
            {
                availableBytes = ExtendHelper.GetMaximumSizeToExtendPartition(partition);
            }
            else // Removable volume
            {
                availableBytes = additionalNumberOfSectors * volume.BytesPerSector;
            }

            TrueCryptHeader header = volume.Header;
            long            oldBackupHeaderOffset = (long)(header.MasterKeyScopeOffset + header.MasterKeyEncryptedAreaSize);
            long            newBackupHeaderOffset = (long)(header.MasterKeyScopeOffset + header.MasterKeyEncryptedAreaSize + (ulong)availableBytes);

            header.MasterKeyEncryptedAreaSize += (ulong)availableBytes;
            header.VolumeSize += (ulong)availableBytes;
            byte[] headerBytes = header.GetBytes(password);
            // Read backup header group from old end of the partition
            byte[] backupHeaderGroupBytes = partition.ReadSectors(oldBackupHeaderOffset / disk.BytesPerSector, TrueCryptVolume.VolumeHeaderGroupLength / disk.BytesPerSector);
            // Updated the backup header (using the stored salt)
            header.Salt = ByteReader.ReadBytes(backupHeaderGroupBytes, 0, 64);
            byte[] backupHeaderBytes = header.GetBytes(password);
            Array.Copy(backupHeaderBytes, 0, backupHeaderGroupBytes, 0, backupHeaderBytes.Length);

            if (partition is MBRPartition || partition is GPTPartition)
            {
                long availableSectors = availableBytes / disk.BytesPerSector;
                ExtendHelper.ExtendPartition((Partition)partition, availableSectors);
                // Reinitialize the partition
                partition = VolumeSelectionHelper.GetLastPartition(disk);
            }

            // Write backup header to the new end of the partition
            partition.WriteSectors(newBackupHeaderOffset / disk.BytesPerSector, backupHeaderGroupBytes);

            // Destroy the old backup header (to prevent decryption of the volume after the password has changed)
            byte[] temp = new byte[TrueCryptVolume.VolumeHeaderGroupLength];
            new Random().NextBytes(temp);
            partition.WriteSectors(oldBackupHeaderOffset / disk.BytesPerSector, temp);

            // Write an updated header
            partition.WriteSectors(0, headerBytes);

            return(TrueCryptResizeStatus.Success);
        }
示例#19
0
        /// <summary>
        /// 生成会员卡
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public OpResult GenerateMemberCard(string ids)
        {
            try
            {
                var datas = _service.GetMakingMembershipCardByIds(ids);

                if (datas == null || datas.Count == 0)
                {
                    return(new OpResult()
                    {
                        Successed = false, Message = "找不到原数据!"
                    });
                }
                //var sw = new Stopwatch();

                var securityCodes = BaseService <MembershipCard> .CurrentRepository.Entities.Where(o => o.CompanyId == CommonService.CompanyId).Select(o => o.SecurityCode).ToList();

                var cardTypeIds  = datas.Select(o => o.CardTypeId).ToList();
                var cardTypeInfo = BaseService <CardInfo> .CurrentRepository.Entities.Where(o => cardTypeIds.Contains(o.CardTypeId)).ToDictionary(o => o.CardTypeId, o => o);

                var areaCode = string.Empty;

                //统计当前的所有批次
                var batchs = string.Empty;
                //生成相应会员卡信息
                foreach (var item in datas)
                {
                    //查询当前cid区号
                    if (string.IsNullOrEmpty(areaCode))
                    {
                        var companyEntity = BaseService <OMS_CompanyAuthorize> .CurrentRepository.Entities.FirstOrDefault(o => o.Code == item.CompanyId);

                        if (companyEntity == null)
                        {
                            areaCode = "0000";
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(companyEntity.AreaCode))
                            {
                                areaCode = companyEntity.AreaCode;
                            }
                            else
                            {
                                areaCode = "0000";
                            }
                        }
                    }
                    //判断状态 0=未制卡
                    if (item.State == 0)
                    {
                        batchs += "," + item.BatchSN;
                        //生成会员卡数据
                        var membershipCards = new List <MembershipCard>();

                        var         resetSwiftNumber = 0;
                        SwiftNumber swiftNumber      = new SwiftNumber(string.Format("MembershipCard_{0}", item.CompanyId), SwiftNumberMode.Normal);
                        var         swiftNumbers     = swiftNumber.GetNumberRanges(item.MakeNumber, out resetSwiftNumber);
                        //sw.Start();
                        var indexCard = string.Empty;
                        for (int i = 0; i < item.MakeNumber; i++)
                        {
                            var securitycode = ExtendHelper.GetRandomStr(4, (o) => { return(securityCodes.Contains(o)); });
                            securityCodes.Add(securitycode);
                            //1位卡类型   4位区号  7位商户号  7位随机数
                            StringBuilder cardSn = new StringBuilder();
                            if (cardTypeInfo[item.CardTypeId].CardType.Contains(","))
                            {
                                indexCard = "3";
                            }
                            else
                            {
                                indexCard = cardTypeInfo[item.CardTypeId].CardType;
                            }
                            cardSn.Append(indexCard);
                            cardSn.Append(areaCode);
                            cardSn.Append(item.CompanyId.ToString("0000000"));
                            cardSn.Append(swiftNumbers[i].ToString("0000000"));
                            MembershipCard membershipCard = new MembershipCard()
                            {
                                CompanyId     = item.CompanyId,
                                BatchSN       = item.BatchSN,
                                CardSN        = cardSn.ToString(),
                                CardTypeId    = item.CardTypeId,
                                ReChargeTotal = 0m,
                                GiveTotal     = 0m,
                                Balance       = cardTypeInfo[item.CardTypeId].DefaultPrice,
                                Deposit       = 0m,
                                State         = 0,
                                ExpiryStart   = item.ExpiryStart,
                                ExpiryEnd     = item.ExpiryEnd,
                                CreateDT      = DateTime.Now,
                                CreateUID     = Sys.CurrentUser.UID,
                                SecurityCode  = securitycode,
                            };
                            membershipCards.Add(membershipCard);
                        }
                        //更新批次状态
                        _service.UpdateState(1, item.Id.ToString());

                        BluckHelper.BulkInsertAll <MembershipCard>(membershipCards);//5000 0.9767s
                        //BaseService<MembershipCard>.CurrentRepository.AddRange(membershipCards);//5000条1.08分钟

                        swiftNumber.Reset(resetSwiftNumber);
                        //sw.Stop();
                    }
                }
                //var date = sw.Elapsed;
                return(new OpResult()
                {
                    Successed = true, Message = "操作成功!"
                });
            }
            catch (Exception e)
            {
                return(new OpResult()
                {
                    Successed = false, Message = e.Message
                });
            }
        }