Ejemplo n.º 1
0
 public frmContact(object idGroup,string genContact, string tableNameContact)
     : this()
 {
     this.idGroup = HelpNumber.ParseInt64(idGroup);
     this.genContact = genContact;
     this.flag = DataOperation.Add;
     this.tableNameContact = tableNameContact;
 }
Ejemplo n.º 2
0
 public frmGroup(DataOperation operation)
 {
     InitializeComponent();
     if (operation == DataOperation.Add)
         this.Text = "Thêm nhóm mới";
     else
         this.Text = "Sửa nhóm";
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Manufacture and check object ACL against the current session context.
 /// </summary>
 /// <param name="instance"></param>
 /// <param name="op"></param>
 public static void Check(IDataObject instance, DataOperation op)
 {
     // create an instance of an ACL
     string aclClassTypeName = string.Format("Vestris.Service.Data.{0}ClassACL", instance.GetType().Name);
     Type aclClassType = Assembly.GetExecutingAssembly().GetType(aclClassTypeName, true, false);
     object[] args = { instance };
     ACL acl = (ACL)Activator.CreateInstance(aclClassType, args);
     acl.Check((UserContext) SessionManager.CurrentSessionContext, op);
 }
Ejemplo n.º 4
0
 public frmContact(object idGroup, string genContact,string tableNameContact, DataRow dr)
     : this()
 {
     this.idGroup = HelpNumber.ParseInt64(idGroup);
     idContact = HelpNumber.ParseInt64(dr["ID"].ToString());
     this.data = dr;
     this.flag = DataOperation.Edit;
     this.genContact = genContact;
     this.tableNameContact = tableNameContact;
     SetValue(dr);
 }
Ejemplo n.º 5
0
        public Change(string name, object value, DataOperation op = DataOperation.Replace)
        {
            #region Preconditions

            if (name == null) throw new ArgumentNullException(nameof(name));

            #endregion

            Operation = op;
            Name = name;
            Value = value;
        }
Ejemplo n.º 6
0
        public DataRequestObject(DataRequest request)
        {
            Operation = request.Operation;
            OperationName = request.OperationName;
            Arguments = request.OperationArguments;

            ID = request.Query.ID;

            Partition = request.Partition;
            Query = request.Query;
            Item = request.Item;

            Execute = delegate(Dictionary<string, object> options) {
                request.Partition = Partition;
                request.Query = Query;
                request.Item = Item;

                return request.Query.Collection.Source.Execute(request, options);
            };
        }
        public void CreateStatements(string tableName, string filter, DataOperation operation)
        {
            bool isNotView = !IsView(tableName);

            if (isNotView)
                _sqlRemoveConstraints.Add(CreateRemoveContraintsStatement(tableName));

            if ((operation & DataOperation.Delete) == DataOperation.Delete)
                _sqlStatements.Add(CreateDeleteStatement(tableName, filter));

            if ((operation & DataOperation.Insert) == DataOperation.Insert)
            {
                DataTable dt = SelectDataTable(tableName, filter);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                        _sqlStatements.Add(CreateInsertStatement(row, tableName, isNotView));
                }
            }

            if (isNotView)
                _sqlRestoreConstraints.Add(CreateRestoreContraintsStatement(tableName));
        }
        public string Get(DataOperation request)
        {
            try
            {
                // parse the zoom, x and y.
                int x, y, zoom;
                if (!int.TryParse(request.X, out x))
                {
                    // invalid x.
                    throw new InvalidCastException("Cannot parse x-coordinate!");
                }
                if (!int.TryParse(request.Y, out y))
                {
                    // invalid y.
                    throw new InvalidCastException("Cannot parse y-coordinate!");
                }
                if (!int.TryParse(request.Zoom, out zoom))
                {
                    // invalid zoom.
                    throw new InvalidCastException("Cannot parse zoom!");
                }

                // create the filter.
                var tile = new Tile(x, y, zoom);

                // invert the y-coordinate, system of HOT-tasking manager is inverted.
                tile = tile.InvertY();

                // execute the request.
                return (new DataService()).RequestData(request.File, tile.Box);
            }
            catch (Exception ex)
            {
                base.Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return string.Empty;
            }
        }
Ejemplo n.º 9
0
        public override void Withdraw(double money)
        {
            BankEntities context = new BankEntities();
            var          qq      = from t in context.MoneyInfo
                                   where t.dealType == "存款" && t.accountNo == account1
                                   select t;
            var q = qq.FirstOrDefault();

            if (!ValidBeforeWithdraw(money))
            {
                return;
            }
            //存款时间
            date1 = Convert.ToDateTime(q.dealDate);
            //计算利息

            //取款时间
            DateTime date2 = DateTime.Now;

            if (type == RateType.定期1年)
            {
                DYear = 1;
            }
            if (type == RateType.定期3年)
            {
                DYear = 3;
            }
            if (type == RateType.定期5年)
            {
                DYear = 5;
            }
            //1年
            if (DYear == 1 && (date2 - date1).TotalDays >= 365)
            {
                if ((date2 - date1).TotalDays > 365)
                {
                    //超期利息
                    double rate = DataOperation.GetRate(RateType.定期超期部分) * AccountBalance;
                    //添加利息
                    AccountBalance += rate;
                    //取款
                    base.Withdraw(money);
                }
                else
                {
                    base.Withdraw(money);
                }
            }
            else if (DYear == 1 && (date2 - date1).TotalDays < 365)
            {
                AccountBalance -= preRate;
                //不足日期
                double rate = DataOperation.GetRate(RateType.定期提前支取) * AccountBalance;
                //添加利息
                AccountBalance += rate;
                AccountBalance -= preRate;
                //取款
                base.Withdraw(money);
            }



            //3年
            if (DYear == 3 && (date2 - date1).TotalDays >= 365 * 3)
            {
                if ((date2 - date1).TotalDays > 365 * 3)
                {
                    //超期利息
                    double rate = DataOperation.GetRate(RateType.定期超期部分) * AccountBalance;
                    //添加利息
                    AccountBalance += rate;
                    //取款
                    base.Withdraw(money);
                }
                else
                {
                    base.Withdraw(money);
                }
            }
            else if (DYear == 3 && (date2 - date1).TotalDays < 365 * 3)
            {
                AccountBalance -= preRate;
                //不足日期
                double rate = DataOperation.GetRate(RateType.定期提前支取) * AccountBalance;
                //添加利息
                AccountBalance += rate;
                AccountBalance -= preRate;
                //取款
                base.Withdraw(money);
            }


            //5年
            if (DYear == 5 && (date2 - date1).TotalDays >= 365 * 5)
            {
                if ((date2 - date1).TotalDays > 365 * 5)
                {
                    //超期利息
                    double rate = DataOperation.GetRate(RateType.定期超期部分) * AccountBalance;
                    //添加利息
                    AccountBalance += rate;
                    //取款
                    base.Withdraw(money);
                }
                else
                {
                    base.Withdraw(money);
                }
            }
            else if (DYear == 5 && (date2 - date1).TotalDays < 365 * 5)
            {
                AccountBalance -= preRate;
                //不足日期
                double rate = DataOperation.GetRate(RateType.定期提前支取) * AccountBalance;
                //添加利息
                AccountBalance += rate;
                AccountBalance -= preRate;
                //取款
                base.Withdraw(money);
            }
        }
Ejemplo n.º 10
0
 public Task TraceAsync(string data, DataOperation operation)
 {
     File.AppendAllLines(_fileName, new[] { string.Format("{0} - Operation: {1} - Data: {2}", DateTime.UtcNow, operation, data) });
     return(Task.FromResult <object>(null));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OperationErrorEvent" /> class.
 /// </summary>
 /// <param name="operation">The operation.</param>
 /// <param name="exception">The exception.</param>
 /// <param name="properties">The properties.</param>
 public OperationErrorEvent(DataOperation operation, Exception exception, IDictionary <string, string> properties)
 {
     this.Operation  = operation;
     this.Exception  = exception;
     this.Properties = new Dictionary <string, string>(properties);
 }
        static internal AccountBalance GetCurrentBalance(Account account)
        {
            var op = DataOperation.Parse("getAccountBalance", account.Number);

            return(DataReader.GetPlainObject <AccountBalance>(op));
        }
Ejemplo n.º 13
0
 /// <summary>
 /// 第二优先级
 /// </summary>
 /// <param name="table"></param>
 /// <param name="query"></param>
 public CommonSearch(string table, IMongoQuery query)
 {
     _tbName = table;
     _query  = query;
     dataOp  = new DataOperation();
 }
Ejemplo n.º 14
0
        public override ACLVerdict Apply(UserContext ctx, DataOperation op)
        {
            if (ctx.AccountId == 0)
                return ACLVerdict.None;

            if (ctx.AccountId != _accountId)
                return ACLVerdict.None;

            if ((_operation & (int)op) == 0)
                return ACLVerdict.None;

            return _permission == DataOperationPermission.Allow
                ? ACLVerdict.Allowed
                : ACLVerdict.Denied;
        }
Ejemplo n.º 15
0
 public ACLBaseEntry(DataOperation op, DataOperationPermission perm)
     : this((int) op, perm)
 {
 }
Ejemplo n.º 16
0
        public ActionResult SavePostInfo(FormCollection saveForm)
        {
            InvokeResult  result = new InvokeResult();
            DataOperation dataOp = new DataOperation();

            #region 构建数据
            string tbName   = saveForm["tbName"] != null ? saveForm["tbName"] : "";
            string queryStr = saveForm["queryStr"] != null ? saveForm["queryStr"] : "";
            string dataStr  = saveForm["dataStr"] != null ? saveForm["dataStr"] : "";

            if (dataStr.Trim() == "")
            {
                foreach (var tempKey in saveForm.AllKeys)
                {
                    if (tempKey == "tbName" || tempKey == "queryStr" || tempKey.Contains("fileList[") || tempKey.Contains("param."))
                    {
                        continue;
                    }

                    dataStr += string.Format("{0}={1}&", tempKey, saveForm[tempKey]);
                }
            }
            #endregion

            #region 保存数据
            BsonDocument curData = new BsonDocument();  //当前数据,即操作前数据

            if (queryStr.Trim() != "")
            {
                curData = dataOp.FindOneByQuery(tbName, TypeConvert.NativeQueryToQuery(queryStr));
            }

            result = dataOp.Save(tbName, queryStr, dataStr);

            #endregion

            #region 文件上传
            int       primaryKey = 0;
            TableRule rule       = new TableRule(tbName);

            ColumnRule columnRule = rule.ColumnRules.Where(t => t.IsPrimary == true).FirstOrDefault();
            string     keyName    = columnRule != null ? columnRule.Name : "";
            if (!string.IsNullOrEmpty(queryStr))
            {
                var query     = TypeConvert.NativeQueryToQuery(queryStr);
                var recordDoc = dataOp.FindOneByQuery(tbName, query);
                saveForm["keyValue"] = result.BsonInfo.Text(keyName);
                if (recordDoc != null)
                {
                    primaryKey = recordDoc.Int(keyName);
                }
            }

            if (primaryKey == 0)//新建
            {
                if (saveForm["tableName"] != null)
                {
                    string str = result.BsonInfo.Text(keyName);
                    saveForm["keyValue"] = result.BsonInfo.Text(keyName);
                    string t = saveForm["keyValue"].ToString();
                    string c = result.BsonInfo.String(keyName);
                    t = "";
                }
            }
            else//编辑
            {
                #region  除文件
                string delFileRelIds = saveForm["delFileRelIds"] != null ? saveForm["delFileRelIds"] : "";
                if (!string.IsNullOrEmpty(delFileRelIds))
                {
                    FileOperationHelper opHelper = new FileOperationHelper();
                    try
                    {
                        string[] fileArray;
                        if (delFileRelIds.Length > 0)
                        {
                            fileArray = delFileRelIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                            if (fileArray.Length > 0)
                            {
                                foreach (var item in fileArray)
                                {
                                    result = opHelper.DeleteFileByRelId(int.Parse(item));
                                    if (result.Status == Status.Failed)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        result.Status  = Status.Failed;
                        result.Message = ex.Message;
                        return(Json(TypeConvert.InvokeResultToPageJson(result)));
                    }
                }
                #endregion

                saveForm["keyValue"] = primaryKey.ToString();
            }
            result.FileInfo = SaveMultipleUploadFiles(saveForm);
            #endregion

            #region 保存日志
            if (result.Status == Status.Successful)
            {
                //dataOp.LogDataStorage(tbName, queryStr.Trim() == "" ? StorageType.Insert : StorageType.Update, curData, result.BsonInfo);
            }
            #endregion

            return(Json(TypeConvert.InvokeResultToPageJson(result)));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 上传多个文件
        /// </summary>
        /// <param name="saveForm"></param>
        /// <returns></returns>
        public string SaveMultipleUploadFiles(FormCollection saveForm)
        {
            DataOperation dataOp = new DataOperation();

            string tableName    = PageReq.GetForm("tableName");
            string keyName      = PageReq.GetForm("keyName");
            string keyValue     = saveForm["keyValue"].ToString();
            string localPath    = PageReq.GetForm("uploadFileList");
            string fileSaveType = saveForm["fileSaveType"] != null ? saveForm["fileSaveType"] : "multiply";
            int    fileTypeId   = PageReq.GetFormInt("fileTypeId");
            int    fileObjId    = PageReq.GetFormInt("fileObjId");
            int    uploadType   = PageReq.GetFormInt("uploadType");
            string subMapParam  = PageReq.GetForm("subMapParam");
            string guid2d       = PageReq.GetForm("guid2d");
            string oldGuid2d    = PageReq.GetForm("oldguid2d");
            bool   isPreDefine  = saveForm["isPreDefine"] != null?bool.Parse(saveForm["isPreDefine"]) : false;

            Dictionary <string, string> propDic  = new Dictionary <string, string>();
            FileOperationHelper         opHelper = new FileOperationHelper();
            List <InvokeResult <FileUploadSaveResult> > result = new List <InvokeResult <FileUploadSaveResult> >();

            localPath = localPath.Replace("\\\\", "\\");

            #region 如果保存类型为单个single 则删除旧的所有关联文件
            if (!string.IsNullOrEmpty(fileSaveType))
            {
                if (fileSaveType == "single")
                {
                    opHelper.DeleteFile(tableName, keyName, keyValue);
                }
            }
            #endregion

            #region 通过关联读取对象属性
            if (!string.IsNullOrEmpty(localPath.Trim()))
            {
                string[] fileStr = Regex.Split(localPath, @"\|H\|", RegexOptions.IgnoreCase);
                Dictionary <string, string> filePath = new Dictionary <string, string>();
                foreach (string file in fileStr)
                {
                    string[] filePaths = Regex.Split(file, @"\|Y\|", RegexOptions.IgnoreCase);

                    if (filePaths.Length > 0)
                    {
                        string[] subfile = Regex.Split(filePaths[0], @"\|Z\|", RegexOptions.IgnoreCase);
                        if (subfile.Length > 0)
                        {
                            if (!filePath.Keys.Contains(subfile[0]))
                            {
                                if (filePaths.Length >= 2)
                                {
                                    filePath.Add(subfile[0], filePaths[1]);
                                }
                                else
                                {
                                    filePath.Add(subfile[0], "");
                                }
                            }
                        }
                    }
                }

                if (fileObjId != 0)
                {
                    List <BsonDocument> docs = new List <BsonDocument>();
                    docs = dataOp.FindAllByKeyVal("FileObjPropertyRelation", "fileObjId", fileObjId.ToString()).ToList();

                    List <string> strList = new List <string>();
                    strList = docs.Select(t => t.Text("filePropId")).Distinct().ToList();
                    var doccList = dataOp.FindAllByKeyValList("FileProperty", "filePropId", strList);
                    foreach (var item in doccList)
                    {
                        var formValue = saveForm[item.Text("dataKey")];
                        if (formValue != null)
                        {
                            propDic.Add(item.Text("dataKey"), formValue.ToString());
                        }
                    }
                }

                List <FileUploadObject> singleList = new List <FileUploadObject>(); //纯文档上传
                List <FileUploadObject> objList    = new List <FileUploadObject>(); //当前传入类型文件上传
                foreach (var str in filePath)
                {
                    FileUploadObject obj = new FileUploadObject();
                    obj.fileTypeId   = fileTypeId;
                    obj.fileObjId    = fileObjId;
                    obj.localPath    = str.Key;
                    obj.tableName    = tableName;
                    obj.keyName      = keyName;
                    obj.keyValue     = keyValue;
                    obj.uploadType   = uploadType;
                    obj.isPreDefine  = isPreDefine;
                    obj.isCover      = false;
                    obj.propvalueDic = propDic;
                    obj.rootDir      = str.Value;
                    obj.subMapParam  = subMapParam;
                    obj.guid2d       = guid2d;
                    if (uploadType != 0 && (obj.rootDir == "null" || obj.rootDir.Trim() == ""))
                    {
                        singleList.Add(obj);
                    }
                    else
                    {
                        objList.Add(obj);
                    }
                }

                result = opHelper.UploadMultipleFiles(objList, (UploadType)uploadType);//(UploadType)uploadType
                if (singleList.Count > 0)
                {
                    result = opHelper.UploadMultipleFiles(singleList, (UploadType)0);
                }
            }
            else
            {
                PageJson jsonone = new PageJson();
                jsonone.Success = false;
                return(jsonone.ToString() + "|");
            }
            #endregion

            PageJson json = new PageJson();
            var      ret  = opHelper.ResultConver(result);

            #region 如果有关联的文件Id列表,则保存关联记录
            string     fileVerIds    = PageReq.GetForm("fileVerIds");
            List <int> fileVerIdList = fileVerIds.SplitToIntList(",");

            if (ret.Status == Status.Successful && fileVerIdList.Count > 0)
            {
                List <StorageData> saveList = new List <StorageData>();
                foreach (var tempVerId in fileVerIdList)
                {
                    StorageData tempData = new StorageData();

                    tempData.Name     = "FileAlterRelation";
                    tempData.Type     = StorageType.Insert;
                    tempData.Document = new BsonDocument().Add("alterFileId", result.FirstOrDefault().Value.fileId.ToString())
                                        .Add("fileVerId", tempVerId);

                    saveList.Add(tempData);
                }

                dataOp.BatchSaveStorageData(saveList);
            }
            #endregion

            json.Success = ret.Status == Status.Successful ? true : false;
            var strResult = json.ToString() + "|" + ret.Value + "|" + keyValue;
            return(strResult);
        }
        /// <summary>
        /// 导出所选后备干部简要情况登记表
        /// </summary>
        /// <param name="idlist">所选后备干部id号集合</param>
        public void exportword(ArrayList idlist)  //建议把Datatable类型的参数传过来,建议读视图。
        {
            //弹出对话框,选择保存的路径
            #region
            string         savepath = "";
            SaveFileDialog sa       = new SaveFileDialog();
            sa.Filter   = "Document(*.doc)|*.doc";
            sa.FileName = "简要情况登记表";
            if (sa.ShowDialog() == DialogResult.OK)
            {
                savepath = sa.FileName;
            }
            else
            {
                return;
            }
            #endregion

            //创建word应用程序
            wordappliction = new Word.Application();

            //打开指定路径的内容
            #region
            object filepath = System.Windows.Forms.Application.StartupPath + "\\wordModel" + "\\简要情况.doc";
            mydoc = wordappliction.Documents.Open(ref filepath, ref missing, ref readOnly,
                                                  ref missing, ref missing, ref missing, ref missing, ref missing,
                                                  ref missing, ref missing, ref missing, ref isVisible, ref missing,
                                                  ref missing, ref missing, ref missing);
            #endregion
            ////设置word创建的word程序的可见性
            wordappliction.Visible = true;

            //将整个活动区域全部复制
            #region
            mydoc.ActiveWindow.Selection.WholeStory();
            mydoc.ActiveWindow.Selection.Copy();
            #endregion

            string selectid = "";

            for (int i = 0; i < idlist.Count; i++)
            {
                if (i == idlist.Count - 1)
                {
                    selectid = selectid + "'" + idlist[i] + "'";
                }
                else
                {
                    selectid = selectid + "'" + idlist[i] + "',";
                }
            }

            ImageCollection(selectid);

            //读取后备干部的相关信息
            string        sql        = "select * from TB_CommonInfo order by rank, joinTeam desc";
            string        cond       = "cid in (" + selectid + ")";
            DataOperation dataOp     = new DataOperation();
            DataTable     datatableT = dataOp.GetOneDataTable_sql(sql);
            DataTable     datatable  = new DataTable();
            datatable = datatableT.Clone();
            DataView dv = datatableT.AsDataView();
            dv.RowFilter = cond;
            datatable    = dv.ToTable();

            Object myobj = Missing.Value;
            for (int i = 0; i < datatable.Rows.Count - 1; i++)
            {
                //加入两段避免了最后一行文本被弄到下面
                Word.Paragraph para1;
                Word.Paragraph para2;
                para1 = mydoc.Content.Paragraphs.Add(ref myobj);
                para2 = mydoc.Content.Paragraphs.Add(ref myobj);
                object pBreak = (int)WdBreakType.wdSectionBreakNextPage;
                para2.Range.InsertBreak(ref pBreak);
                //调用粘贴方法即可粘贴剪贴板中的内容。
                para2.Range.Paste();
            }
            Shape s = null;
            for (int i = 0; i < datatable.Rows.Count; i++)
            {
                mydoc.ActiveWindow.Selection.WholeStory();
                wordappliction.Selection.Tables[2 * i + 1].Cell(1, 2).Range.Text = datatable.Rows[i]["name"].ToString(); //姓名
                wordappliction.Selection.Tables[2 * i + 1].Cell(1, 4).Range.Text = datatable.Rows[i]["sex"].ToString();  //性别;
                string age = datatable.Rows[i]["birthday"].ToString().Replace("年", ".");

                int nowAge = 0;
                int temp1  = Convert.ToInt32(datatable.Rows[i]["birthday"].ToString().Substring(5, 2));
                int now1   = Convert.ToInt32(DateTime.Now.ToString("MM"));
                int temp2  = Convert.ToInt32(datatable.Rows[i]["birthday"].ToString().Substring(0, 4));
                int now2   = Convert.ToInt32(DateTime.Now.ToString("yyyy"));
                if (temp1 <= now1)
                {
                    nowAge = now2 - temp2;
                }
                else
                {
                    nowAge = now2 - temp2 - 1;
                }
                wordappliction.Selection.Tables[2 * i + 1].Cell(1, 6).Range.Text = age.Replace("月", "") + "\n(" + nowAge + "岁)"; //出生年月

                string filepath1 = System.Windows.Forms.Application.StartupPath + "\\图片夹\\" + datatable.Rows[i]["cid"].ToString() + ".jpg";

                if (System.IO.File.Exists(filepath1))
                {
                    double height    = 0.0;
                    double width     = 0.0;
                    Image  pic       = Image.FromFile(filepath1); //strFilePath是该图片的绝对路径
                    int    intWidth  = pic.Width;                 //长度像素值
                    int    intHeight = pic.Height;                //高度像素值
                    pic.Dispose();
                    if ((double)intHeight / intWidth > 118 / 91.0)
                    {
                        height = 118;
                        width  = 118 * (double)intWidth / intHeight;
                    }
                    else
                    {
                        width  = 91;
                        height = 91 * (double)intHeight / intWidth;
                    }
                    object LinkToFile       = false;
                    object SaveWithDocument = true;
                    object Anchor           = wordappliction.Selection.Tables[2 * i + 1].Cell(1, 7).Range;

                    wordappliction.ActiveDocument.InlineShapes.AddPicture(filepath1, ref LinkToFile, ref SaveWithDocument, ref Anchor);

                    wordappliction.ActiveDocument.InlineShapes[1].Select();
                    wordappliction.ActiveDocument.InlineShapes[1].Width = (int)width;   //图片宽度

                    wordappliction.ActiveDocument.InlineShapes[1].Height = (int)height; //图片高度
                    try
                    {
                        s = wordappliction.ActiveDocument.InlineShapes[1].ConvertToShape();
                        s.WrapFormat.Type = Word.WdWrapType.wdWrapNone;
                        s = null;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    mydoc.ActiveWindow.Selection.WholeStory();
                }

                wordappliction.Selection.Tables[2 * i + 1].Cell(2, 2).Range.Text = datatable.Rows[i]["nation"].ToString();                                                      //民族
                wordappliction.Selection.Tables[2 * i + 1].Cell(2, 4).Range.Text = datatable.Rows[i]["native"].ToString();                                                      //籍贯
                wordappliction.Selection.Tables[2 * i + 1].Cell(2, 6).Range.Text = datatable.Rows[i]["birthplace"].ToString();                                                  //出生地
                string partytime = datatable.Rows[i]["partyTime"].ToString().Replace("年", ".");
                wordappliction.Selection.Tables[2 * i + 1].Cell(3, 2).Range.Text = partytime.Replace("月", "");                                                                  //入党时间
                string worktime = datatable.Rows[i]["workTime"].ToString().Replace("年", ".");
                wordappliction.Selection.Tables[2 * i + 1].Cell(3, 4).Range.Text  = worktime.Replace("月", "");                                                                  //参加工作时间
                wordappliction.Selection.Tables[2 * i + 1].Cell(3, 6).Range.Text  = datatable.Rows[i]["health"].ToString();                                                     //健康状况
                wordappliction.Selection.Tables[2 * i + 1].Cell(4, 2).Range.Text  = datatable.Rows[i]["technicalPost"].ToString();                                              //专业技术职务
                wordappliction.Selection.Tables[2 * i + 1].Cell(4, 4).Range.Text  = datatable.Rows[i]["specialtySkill"].ToString();                                             //熟悉专业有何专长
                wordappliction.Selection.Tables[2 * i + 1].Cell(5, 3).Range.Text  = datatable.Rows[i]["fullEducation"].ToString() + datatable.Rows[i]["fullDegree"].ToString(); //全日制教育
                wordappliction.Selection.Tables[2 * i + 1].Cell(5, 5).Range.Text  = datatable.Rows[i]["fullSchool"].ToString() + datatable.Rows[i]["fullSpecialty"].ToString(); //毕业院校及专业
                wordappliction.Selection.Tables[2 * i + 1].Cell(6, 3).Range.Text  = datatable.Rows[i]["workEducation"].ToString() + datatable.Rows[i]["workDegree"].ToString(); //在职教育
                wordappliction.Selection.Tables[2 * i + 1].Cell(6, 5).Range.Text  = datatable.Rows[i]["workGraduate"].ToString() + datatable.Rows[i]["workSpecialty"].ToString();
                wordappliction.Selection.Tables[2 * i + 1].Cell(7, 2).Range.Text  = datatable.Rows[i]["position"].ToString();
                wordappliction.Selection.Tables[2 * i + 1].Cell(8, 2).Range.Text  = datatable.Rows[i]["knowField"].ToString();
                wordappliction.Selection.Tables[2 * i + 1].Cell(9, 2).Range.Text  = datatable.Rows[i]["trainDirection"].ToString();       //"培养方向";
                wordappliction.Selection.Tables[2 * i + 1].Cell(10, 2).Range.Text = datatable.Rows[i]["trainMeasure"].ToString();         //"培养措施";
                wordappliction.Selection.Tables[2 * i + 1].Cell(11, 2).Range.Text = "\n" + HBresume(datatable.Rows[i]["CID"].ToString()); //"简历";

                //第二页:奖惩情况,年度考核,家庭成员关系
                mydoc.ActiveWindow.Selection.WholeStory();                                                                                      //表示在选中的范围内
                wordappliction.Selection.Tables[2 * i + 2].Cell(1, 2).Range.Text = HBrewardsAndpunishment(datatable.Rows[i]["CID"].ToString()); //"奖惩情况";
                wordappliction.Selection.Tables[2 * i + 2].Cell(2, 2).Range.Text = HByearcheck(datatable.Rows[i]["CID"].ToString());            // "年度考核结果";\

                //得到该干部的家庭信息
                DataTable famliy_dt = dataOp.GetOneDataTable_sql("select * from TB_Family where cid ='" + datatable.Rows[i]["CID"].ToString() + "'");

                int n = famliy_dt.Rows.Count; //家庭人员的个数
                for (int j = 0; j < n; j++)
                {
                    wordappliction.Selection.Tables[2 * i + 2].Cell(j + 4, 2).Range.Text = famliy_dt.Rows[j]["relationship"].ToString(); //"称谓";
                    wordappliction.Selection.Tables[2 * i + 2].Cell(j + 4, 3).Range.Text = famliy_dt.Rows[j]["name"].ToString();         //"姓名";
                    if (famliy_dt.Rows[j]["age"].ToString() == "0")
                    {
                        wordappliction.Selection.Tables[2 * i + 2].Cell(j + 4, 4).Range.Text = "";
                    }
                    else
                    {
                        wordappliction.Selection.Tables[2 * i + 2].Cell(j + 4, 4).Range.Text = famliy_dt.Rows[j]["age"].ToString(); //"年龄";
                    }
                    wordappliction.Selection.Tables[2 * i + 2].Cell(j + 4, 5).Range.Text = famliy_dt.Rows[j]["party"].ToString();   //"政治面貌";
                    if (famliy_dt.Rows[j]["remark"].ToString().Trim() == "已故")
                    {
                        wordappliction.Selection.Tables[2 * i + 2].Cell(j + 4, 6).Range.Text = famliy_dt.Rows[j]["deptJob"].ToString() + "(已故)";//"工作单位及职务";
                    }
                    else
                    {
                        wordappliction.Selection.Tables[2 * i + 2].Cell(j + 4, 6).Range.Text = famliy_dt.Rows[j]["deptJob"].ToString();//"工作单位及职务";
                    }
                }
            }
            //把文件保存在选定的保存路径上
            #region
            object path = savepath;
            //wordappliction.Documents.Save(path);
            mydoc.SaveAs(ref path, ref myobj, ref myobj, ref myobj, ref myobj, ref myobj,
                         ref myobj, ref myobj, ref myobj, ref myobj, ref myobj, ref myobj,
                         ref myobj, ref myobj, ref myobj, ref myobj);
            #endregion

            //关闭退出文档
            #region
            //关闭文档
            mydoc.Close(ref myobj, ref myobj, ref myobj);

            //退出应用程序。
            wordappliction.Quit();
            #endregion
            MessageBox.Show("导出成功!");
            return;
        }
 public HuXiuDetailCrawler(CrawlSettings _Settings, BloomFilter <string> _filter, DataOperation _dataop)
 {
     this.Settings = _Settings;
     this.filter   = _filter;
     this.dataop   = _dataop;
 }
Ejemplo n.º 20
0
 /// <summary>
 /// 构造器
 /// </summary>
 /// <returns></returns>
 public static EpsSummaryBll _(DataOperation ctx)
 {
     return(new EpsSummaryBll(ctx));
 }
Ejemplo n.º 21
0
 private EpsSummaryBll(DataOperation ctx)
 {
     _ctx = ctx;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 封闭当前默认构造函数
 /// </summary>
 private EpsSummaryBll()
 {
     _ctx = new DataOperation();
 }
Ejemplo n.º 23
0
        public async Task TraceAsync(string data, DataOperation operation)
        {
            var envelopeViewModel = new EnvelopeViewModel(false)
            {
                IsRaw = true,
                Json = data,
                Direction = operation
            };

            await App.Current.Dispatcher.InvokeAsync(() => this.Envelopes.Add(envelopeViewModel));
        }
Ejemplo n.º 24
0
        private string SaveDWGNewVersion(FormCollection saveForm, BsonDocument oldfileDoc, DataOperation dataOp)
        {
            string localPath   = PageReq.GetForm("uploadFileList");
            string name        = PageReq.GetForm("name");
            string subMapParam = PageReq.GetForm("subMapParam");
            string newGuid2d   = PageReq.GetForm("guid2d");

            BsonDocument fileDoc = new BsonDocument();

            fileDoc.Add("version", (oldfileDoc.Int("version") + 1).ToString());
            fileDoc.Add("localPath", localPath);
            fileDoc.Add("ext", Path.GetExtension(localPath));
            fileDoc.Add("name", string.IsNullOrEmpty(name) == true ? Path.GetFileName(localPath) : name);
            fileDoc.Add("subMapParam", subMapParam);
            fileDoc.Add("guid2d", newGuid2d);
            var query = Query.EQ("fileId", oldfileDoc.String("fileId"));

            dataOp.Update("FileLibrary", query, fileDoc);

            BsonDocument fileVerDoc = new BsonDocument();

            fileVerDoc.Add("name", fileDoc.String("name"));
            fileVerDoc.Add("ext", fileDoc.String("ext"));
            fileVerDoc.Add("localPath", localPath);
            fileVerDoc.Add("version", fileDoc.String("version"));
            fileVerDoc.Add("subMapParam", subMapParam);
            fileVerDoc.Add("guid2d", newGuid2d);
            fileVerDoc.Add("fileId", oldfileDoc.String("fileId"));
            InvokeResult result = dataOp.Insert("FileLibVersion", fileVerDoc);

            fileVerDoc = result.BsonInfo;
            int fileRelId = 0;

            if (result.Status == Status.Successful)
            {
                var relResult = dataOp.Update("FileRelation", "db.FileRelation.distinct('_id',{'fileId':'" + fileDoc.String("fileId") + "'})", "version=" + fileDoc.String("version"));
                fileRelId = result.BsonInfo.Int("fileRelId");
            }

            List <FileParam> paramList = new List <FileParam>();
            FileParam        fp        = new FileParam();

            fp.path     = localPath;
            fp.ext      = fileDoc.String("ext");
            fp.strParam = string.Format("{0}@{1}-{2}-{3}", "sysObject", fileRelId, oldfileDoc.String("fileId"), fileVerDoc.String("fileVerId"));
            paramList.Add(fp);
            JavaScriptSerializer script = new JavaScriptSerializer();
            string   strJson            = script.Serialize(paramList);
            PageJson json = new PageJson();

            json.Success = result.Status == Status.Successful ? true : false;
            string keyValue  = saveForm["keyValue"] != null ? saveForm["keyValue"] : "0";
            var    strResult = json.ToString() + "|" + strJson + "|" + keyValue;

            return(strResult);
        }
Ejemplo n.º 25
0
        public bool TryCheck(UserContext ctx, DataOperation op)
        {
            ACLVerdict result = Apply(ctx, op);
            switch (result)
            {
                case ACLVerdict.Denied:
                case ACLVerdict.None:
                    return false;
            }

            return true;
        }
Ejemplo n.º 26
0
 /// 开户
 /// </summary>
 /// <param name="accountNumber">帐号</param>
 /// <param name="money">开户金额</param>
 public override void Create(string accountNumber, double money)
 {
     base.Create(accountNumber, money);
     base.Diposit("结息", DataOperation.GetRate(RateType.活期) * money);
 }
Ejemplo n.º 27
0
        public override ACLVerdict Apply(UserContext ctx, DataOperation op)
        {
            if (op == DataOperation.Retreive && ctx.AccountId != 0)
            {
                return ACLVerdict.Allowed;
            }

            return ACLVerdict.None;
        }
Ejemplo n.º 28
0
        public override ACLVerdict Apply(ManagedSecurityContext sec, DataOperation op)
        {
            if ((op == DataOperation.Create || op == DataOperation.Delete) && sec.Account != null)
            {
                return ACLVerdict.Allowed;
            }

            return ACLVerdict.None;
        }
Ejemplo n.º 29
0
 public override ACLVerdict Apply(UserContext ctx, DataOperation op)
 {
     return (op == DataOperation.Retreive) ? ACLVerdict.Allowed : ACLVerdict.None;
 }
Ejemplo n.º 30
0
        public ACLVerdict Apply(ManagedSecurityContext sec, DataOperation op)
        {
            ACLVerdict current = ACLVerdict.Denied;

            foreach (IACLEntry entry in mAccessControlList)
            {
                ACLVerdict result = entry.Apply(sec, op);
                switch (result)
                {
                    case ACLVerdict.Denied:
                        return ACLVerdict.Denied;
                    case ACLVerdict.Allowed:
                        current = ACLVerdict.Allowed;
                        break;
                }
            }

            return current;
        }
Ejemplo n.º 31
0
 /// <summary>
 /// 优先级最高
 /// </summary>
 /// <param name="table"></param>
 /// <param name="query"></param>
 public CommonSearch(string table, string queryStr)
 {
     _tbName   = table;
     _queryStr = queryStr;
     dataOp    = new DataOperation();
 }
Ejemplo n.º 32
0
 public void Check(ManagedSecurityContext sec, DataOperation op)
 {
     if (!TryCheck(sec, op))
     {
         throw new ManagedAccount.AccessDeniedException();
     }
 }
Ejemplo n.º 33
0
 /// <summary>
 ///  第三优先级
 /// </summary>
 /// <param name="table"></param>
 public CommonSearch(string table)
 {
     _tbName = table;
     dataOp  = new DataOperation();
 }
Ejemplo n.º 34
0
 public override ACLVerdict Apply(ManagedSecurityContext sec, DataOperation op)
 {
     return (op == DataOperation.Retreive) ? ACLVerdict.Allowed : ACLVerdict.None;
 }
Ejemplo n.º 35
0
        /// <summary>
        /// 获取项目节点树形XML
        /// </summary>
        /// <param name="tbName"></param>
        /// <param name="curNodeId"></param>
        /// <param name="typeObjId"></param>
        /// <param name="itself"></param>
        /// <returns></returns>
        public JsonResult GetProjNodeTreeJson(string tbName, string curNodeId, int typeObjId, int itself)
        {
            DataOperation dataOp      = new DataOperation();
            TableRule     tableEntity = new TableRule(tbName);                                                 //获取表结构

            string primaryKey = tableEntity.ColumnRules.Where(t => t.IsPrimary == true).FirstOrDefault().Name; //寻找默认主键

            List <BsonDocument> allNodeList = new List <BsonDocument>();

            if (curNodeId.Trim() != "0" && curNodeId != "")
            {
                BsonDocument curNode = dataOp.FindOneByKeyVal(tbName, primaryKey, curNodeId);

                if (typeObjId != 0)
                {
                    allNodeList = dataOp.FindChildNodes(tbName, curNodeId).Where(t => t.Int("typeObjId") == typeObjId).ToList();
                }
                else
                {
                    allNodeList = dataOp.FindChildNodes(tbName, curNodeId).ToList();
                }

                if (itself == 1)
                {
                    allNodeList.Add(curNode);
                }
            }
            else
            {
                if (typeObjId != 0)
                {
                    allNodeList = dataOp.FindAll(tbName).Where(t => t.Int("typeObjId") == typeObjId).ToList();
                }
                else
                {
                    allNodeList = dataOp.FindAll(tbName).ToList();
                }
            }
            allNodeList = allNodeList.OrderBy(a => a.String("nodeKey")).ToList();
            List <Item> treeList = new List <Item>();

            if (allNodeList.Count > 0)
            {
                string tabString       = "---";
                int    parentNodeLevel = allNodeList[0].Int("nodeLevel");
                foreach (var node in allNodeList)
                {
                    int    tabCount      = node.Int("nodeLevel") - parentNodeLevel;
                    string nodeTabString = string.Empty;
                    for (int i = 0; i < tabCount; i++)
                    {
                        nodeTabString += tabString;
                    }
                    treeList.Add(new Item()
                    {
                        id   = node.Int("nodeId"),
                        name = string.Format("{0}{1}", nodeTabString, node.String("name"))
                    });
                }
            }
            return(Json(treeList, JsonRequestBehavior.AllowGet));
        }
 /// <summary>
 /// 谁的那个
 /// </summary>
 /// <param name="_Settings"></param>
 /// <param name="filter"></param>
 public QCCEnterpriseDetailInfoGuidAdd(CrawlSettings _Settings, BloomFilter <string> _filter, DataOperation _dataop)
 {
     Settings = _Settings; filter = _filter; dataop = _dataop;
 }
Ejemplo n.º 37
0
	  /// <summary>
	  /// This method will return an ArrayList of IDataOperations that the ElementMapper provides when
	  /// mapping from the ElementType specified in the method argument. 
	  /// </summary>
	  /// <remarks>
	  ///  Each IDataOperation object will contain 3 IArguments:
	  ///  <p> [Key]              [Value]                      [ReadOnly]    [Description]----------------- </p>
	  ///  <p> ["Type"]           ["SpatialMapping"]           [true]        ["Using the ElementMapper"] </p>
	  ///  <p> ["ID"]             [The Operation ID]           [true]        ["Internal ElementMapper dataoperation ID"] </p>
	  ///  <p> ["Description"]    [The Operation Description]  [true]        ["Using the ElementMapper"] </p>
	  ///  <p> ["ToElementType"]  [ElementType]                [true]        ["Valid To-Element Types"]  </p>
	  /// </remarks>
	  /// <param name="fromElementsElementType"></param>
	  /// <returns>
	  ///  ArrayList which contains the available dataOperations (IDataOperation).
	  /// </returns>
	  public ArrayList GetAvailableDataOperations(ElementType fromElementsElementType)
	  {
		  ArrayList availableDataOperations = new ArrayList();

		  for ( int i = 0; i < _availableMethods.Length; i++)
		  {
			  if( fromElementsElementType == _availableMethods[i].fromElementsShapeType)
			  {
				  DataOperation dataOperation = new DataOperation("ElementMapper" + _availableMethods[i].ID);
				  dataOperation.AddArgument(new Argument("ID",_availableMethods[i].ID.ToString(),true,"Internal ElementMapper dataoperation ID"));
				  dataOperation.AddArgument(new Argument("Description",_availableMethods[i].Description,true,"Operation description"));
				  dataOperation.AddArgument(new Argument("Type","SpatialMapping",true,"Using the ElementMapper"));
				  dataOperation.AddArgument(new Argument("FromElementType",_availableMethods[i].fromElementsShapeType.ToString(),true,"Valid From-Element Types"));
				  dataOperation.AddArgument(new Argument("ToElementType",_availableMethods[i].toElementsShapeType.ToString(),true,"Valid To-Element Types"));
				  availableDataOperations.Add(dataOperation);
			  }
		  }
		  return availableDataOperations;
	  }
 List <BsonDocument> allLandUrlList = new List <BsonDocument>(); //没有县市的Url
 /// <summary>
 /// 谁的那个
 /// </summary>
 /// <param name="_Settings"></param>
 /// <param name="filter"></param>
 public ProfileCompanyCrawler_BaiCheng(CrawlSettings _Settings, BloomFilter <string> _filter, DataOperation _dataop)
 {
     Settings = _Settings; filter = _filter; dataop = _dataop;
 }
Ejemplo n.º 39
0
        public override ACLVerdict Apply(ManagedSecurityContext sec, DataOperation op)
        {
            if (sec.Account == null)
                return ACLVerdict.None;

            if (sec.Account.Id != mAccountId)
                return ACLVerdict.None;

            if ((mOperation & (int)op) == 0)
                return ACLVerdict.None;

            return mPermission == DataOperationPermission.Allow
                ? ACLVerdict.Allowed
                : ACLVerdict.Denied;
        }
Ejemplo n.º 40
0
        private void buttonApply_Click(object sender, EventArgs e)
        {
            if (!m_formLoaded || m_formClosing)
            {
                return;
            }

            string serviceConfigFile = FilePath.GetAbsolutePath(textBoxConfigFile.Text);

            if (!File.Exists(serviceConfigFile))
            {
                MessageBox.Show(this, $"Cannot find config file \"{serviceConfigFile}\".", "Cannot Apply Changes", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                XDocument serviceConfig = XDocument.Load(serviceConfigFile);

                //Guid nodeID = Guid.Parse(serviceConfig
                //    .Descendants("systemSettings")
                //    .SelectMany(systemSettings => systemSettings.Elements("add"))
                //    .Where(element => "NodeID".Equals((string)element.Attribute("name"), StringComparison.OrdinalIgnoreCase))
                //    .Select(element => (string)element.Attribute("value"))
                //    .FirstOrDefault() ?? Guid.Empty.ToString());

                string connectionString = serviceConfig
                                          .Descendants("systemSettings")
                                          .SelectMany(systemSettings => systemSettings.Elements("add"))
                                          .Where(element => "ConnectionString".Equals((string)element.Attribute("name"), StringComparison.OrdinalIgnoreCase))
                                          .Select(element => (string)element.Attribute("value"))
                                          .FirstOrDefault();

                string dataProviderString = serviceConfig
                                            .Descendants("systemSettings")
                                            .SelectMany(systemSettings => systemSettings.Elements("add"))
                                            .Where(element => "DataProviderString".Equals((string)element.Attribute("name"), StringComparison.OrdinalIgnoreCase))
                                            .Select(element => (string)element.Attribute("value"))
                                            .FirstOrDefault();

                string serviceName = serviceConfig
                                     .Descendants("securityProvider")
                                     .SelectMany(securitySettings => securitySettings.Elements("add"))
                                     .Where(element => "ApplicationName".Equals((string)element.Attribute("name"), StringComparison.OrdinalIgnoreCase))
                                     .Select(element => (string)element.Attribute("value"))
                                     .FirstOrDefault();

                string    managerConfigFile   = $"{FilePath.GetDirectoryName(serviceConfigFile)}{serviceName}Manager.exe.config";
                XDocument managerConfig       = null;
                bool      applyManagerChanges = true;

                if (!File.Exists(managerConfigFile))
                {
                    if (MessageBox.Show(this, $"Failed to associated manager config file \"{managerConfigFile}\". Do you want to continue with changes to service only?", "Manager Config Not Found", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }

                    applyManagerChanges = false;
                }

                if (applyManagerChanges)
                {
                    managerConfig = XDocument.Load(managerConfigFile);
                }

                // Attempt to access service controller for the specified Windows service
                ServiceController serviceController = ServiceController.GetServices().SingleOrDefault(svc => string.Compare(svc.ServiceName, serviceName, StringComparison.OrdinalIgnoreCase) == 0);

                if (serviceController != null)
                {
                    try
                    {
                        if (serviceController.Status == ServiceControllerStatus.Running)
                        {
                            m_log.Publish(MessageLevel.Info, $"Attempting to stop the {serviceName} Windows service...");

                            serviceController.Stop();

                            // Can't wait forever for service to stop, so we time-out after 20 seconds
                            serviceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(20.0D));

                            if (serviceController.Status == ServiceControllerStatus.Stopped)
                            {
                                m_log.Publish(MessageLevel.Info, $"Successfully stopped the {serviceName} Windows service.");
                            }
                            else
                            {
                                m_log.Publish(MessageLevel.Info, $"Failed to stop the {serviceName} Windows service after trying for 20 seconds...");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.SwallowException(ex, $"Failed to stop the {serviceName} Windows service: {ex.Message}");
                    }
                }

                // If the service failed to stop or it is installed as stand-alone debug application, we try to forcibly stop any remaining running instances
                Process[] instances = Process.GetProcessesByName(serviceName);

                if (instances.Length > 0)
                {
                    int total = 0;
                    m_log.Publish(MessageLevel.Info, $"Attempting to stop running instances of the {serviceName}...");

                    // Terminate all instances of service running on the local computer
                    foreach (Process process in instances)
                    {
                        process.Kill();
                        total++;
                    }

                    if (total > 0)
                    {
                        m_log.Publish(MessageLevel.Info, $"Stopped {total} {serviceName} instance{(total > 1 ? "s" : "")}.");
                    }
                }

                // Mark phasor data source validation to rename all point tags at next configuration reload
                using (AdoDataConnection connection = new AdoDataConnection(connectionString, dataProviderString))
                {
                    string filterExpression = "MethodName = 'PhasorDataSourceValidation'";
                    TableOperations <DataOperation> dataOperationTable = new TableOperations <DataOperation>(connection);
                    DataOperation record = dataOperationTable.QueryRecordWhere(filterExpression);

                    if (record == null)
                    {
                        string errorMessage = $"Failed to find DataOperation record with {filterExpression}.";
                        m_log.Publish(MessageLevel.Error, "ApplyChanges", errorMessage);
                        MessageBox.Show(this, errorMessage, "Cannot Apply Changes", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    record.Arguments = "renameAllPointTags=true";
                    dataOperationTable.UpdateRecordWhere(record, filterExpression);
                }

                // Update point tag name expression in config files
                XElement servicePointTagExpression = serviceConfig
                                                     .Descendants("systemSettings")
                                                     .SelectMany(securitySettings => securitySettings.Elements("add"))
                                                     .FirstOrDefault(element => "PointTagNameExpression".Equals((string)element.Attribute("name"), StringComparison.OrdinalIgnoreCase));

                XAttribute value = servicePointTagExpression?.Attribute("value");

                if (value != null)
                {
                    value.Value = textBoxExpression.Text;
                    serviceConfig.Save(serviceConfigFile);
                }

                XElement managerPointTagExpression = managerConfig?
                                                     .Descendants("systemSettings")
                                                     .SelectMany(securitySettings => securitySettings.Elements("add"))
                                                     .FirstOrDefault(element => "PointTagNameExpression".Equals((string)element.Attribute("name"), StringComparison.OrdinalIgnoreCase));

                value = managerPointTagExpression?.Attribute("value");

                if (value != null)
                {
                    value.Value = textBoxExpression.Text;
                    managerConfig.Save(managerConfigFile);
                }

                if (checkBoxSetPortNumber.Checked)
                {
                    // Update STTP port number
                    XElement sttpConfigString = serviceConfig
                                                .Descendants("sttpdatapublisher")
                                                .SelectMany(securitySettings => securitySettings.Elements("add"))
                                                .FirstOrDefault(element => "ConfigurationString".Equals((string)element.Attribute("name"), StringComparison.OrdinalIgnoreCase));

                    value = sttpConfigString?.Attribute("value");

                    if (value != null)
                    {
                        value.Value = $"port={maskedTextBoxPortNumber.Text}";
                        serviceConfig.Save(serviceConfigFile);
                    }
                }

                // Refresh state in case service process was forcibly stopped
                serviceController.Refresh();

                // Attempt to restart Windows service...
                serviceController.Start();

                Application.Exit();
            }
            catch (Exception ex)
            {
                m_log.Publish(MessageLevel.Error, "ApplyChanges", ex.Message, exception: ex);
                MessageBox.Show(this, $"Exception: {ex.Message}", "Failed to Apply Changes", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 41
0
        public bool TryCheck(ManagedSecurityContext sec, DataOperation op)
        {
            ACLVerdict result = Apply(sec, op);
            switch (result)
            {
                case ACLVerdict.Denied:
                case ACLVerdict.None:
                    return false;
            }

            return true;
        }
Ejemplo n.º 42
0
 /// <summary>
 /// 谁的那个
 /// </summary>
 /// <param name="_Settings"></param>
 /// <param name="filter"></param>
 public Fang99Crawler(CrawlSettings _Settings, BloomFilter <string> _filter, DataOperation _dataop)
 {
     Settings = _Settings; filter = _filter; dataop = _dataop;
 }
Ejemplo n.º 43
0
 public abstract ACLVerdict Apply(ManagedSecurityContext sec, DataOperation op);
Ejemplo n.º 44
0
        protected virtual void AuditDelete(DataStoreContext context, DbEntityEntry targetEntity, DataOperation operation)
        {
            var transactionId = Guid.NewGuid();

            foreach (var prop in targetEntity.OriginalValues.PropertyNames)
            {
                var property   = targetEntity.Property(prop);
                var auditTrail = InitEntity(targetEntity, operation, property, prop, transactionId);
                context.Entry(auditTrail).State = EntityState.Added;
            }
        }
Ejemplo n.º 45
0
        public override ACLVerdict Apply(ManagedSecurityContext sec, DataOperation op)
        {
            if (op == DataOperation.Retreive && sec.Account != null)
            {
                return ACLVerdict.Allowed;
            }

            return ACLVerdict.None;
        }
Ejemplo n.º 46
0
        public override IList <AccountAuditEntry> CreateAccountAuditEntries(ISession session, ManagedSecurityContext sec, DataOperation op)
        {
            List <AccountAuditEntry> result = new List <AccountAuditEntry>();

            switch (op)
            {
            case DataOperation.Create:
                result.Add(ManagedAccountAuditEntry.CreatePublicAccountAuditEntry(session, sec.Account,
                                                                                  string.Format("[user:{0}] posted a new mad lib in [{1}:{2}]",
                                                                                                mInstance.AccountId, mInstance.DataObject.Name.ToLower(), mInstance.ObjectId),
                                                                                  string.Format("{0}View.aspx?id={1}", mInstance.DataObject.Name, mInstance.ObjectId)));
                break;
            }
            return(result);
        }
Ejemplo n.º 47
0
        public Task TraceAsync(string data, DataOperation operation)
        {
            return App.Current.Dispatcher.InvokeAsync(() =>
            {
                if (!string.IsNullOrWhiteSpace(data))
                {
                    DataLenght += data.Length;

                    var json = JObject.Parse(data);
                    json.ToString(Formatting.Indented);
                    var traceData = new TraceDataViewModel()
                    {
                        Operation = operation,
                        Data = json.ToString()
                    };

                    TraceLogs.Add(traceData);

                    while (TraceLogs.Count > TraceLimit)
                    {
                        TraceLogs.RemoveAt(0);
                    }
                }
            }).Task;
        }
Ejemplo n.º 48
0
        /// <inheritdoc />
        protected override void MessageReceived(Message message)
        {
            if (message.Data is JoinAttempt)
            {
                JoinAttempt attempt = (JoinAttempt)message.Data;
                if (attempt.Type != NodeType.Api)
                {
                    SendMessage(new Message(message, new JoinFailure("Only an API node can send a join attempt to a query node."), false)
                    {
                        SendWithoutConfirmation = true
                    });
                }

                if (attempt.Settings != _settings.ConnectionString)
                {
                    SendMessage(new Message(message, new JoinFailure("The connection strings do not match."), false)
                    {
                        SendWithoutConfirmation = true
                    });
                }

                Connections[message.Address].ConnectionEstablished(message.Address, attempt.Type);
                var response = new Message(message, new JoinSuccess(new Document()), true);
                SendMessage(response);
                response.BlockUntilDone();
            }
            else if (message.Data is PrimaryAnnouncement)
            {
                Logger.Log("Setting the primary controller to " + message.Address.ConnectionName, LogLevel.Info);
                Primary = message.Address;
            }
            else if (message.Data is NodeList)
            {
                lock (_connectedStorageNodes)
                {
                    _connectedStorageNodes.Clear();
                    _connectedStorageNodes.AddRange(((NodeList)message.Data).Nodes.Select(e => new NodeDefinition(e.Split(':')[0], int.Parse(e.Split(':')[1]))));

                    var connections = GetConnectedNodes();
                    foreach (var item in _connectedStorageNodes)
                    {
                        if (!connections.Any(e => Equals(e.Item1, item)))
                        {
                            Message attempt = new Message(item, new JoinAttempt(NodeType.Query, _settings.NodeName, _settings.Port, _settings.ConnectionString), true)
                            {
                                SendWithoutConfirmation = true
                            };

                            SendMessage(attempt);
                            attempt.BlockUntilDone();

                            if (attempt.Success)
                            {
                                if (attempt.Response.Data is JoinFailure)
                                {
                                    Logger.Log("Failed to join storage node: " + ((JoinFailure)attempt.Response.Data).Reason, LogLevel.Error);
                                }
                                else
                                {
                                    Connections[item].ConnectionEstablished(item, NodeType.Storage);
                                    SendMessage(new Message(attempt.Response, new Acknowledgement(), false));
                                }
                            }
                        }
                    }
                }
            }
            else if (message.Data is DataOperation)
            {
                DataOperation op            = (DataOperation)message.Data;
                Document      dataOperation = new Document(op.Json);
                if (!dataOperation.Valid)
                {
                    SendMessage(new Message(message, new DataOperationResult(ErrorCodes.InvalidDocument, "The document is invalid."), false));
                    return;
                }

                try
                {
                    ProcessDataOperation(dataOperation, message);
                }
                catch (Exception e)
                {
                    Logger.Log(e.Message + "\nStackTrace:" + e.StackTrace, LogLevel.Error);
                    SendMessage(new Message(message, new DataOperationResult(ErrorCodes.FailedMessage, "An exception occurred while processing the operation."), false));
                }
            }
            else if (message.Data is ChunkListUpdate)
            {
                _chunkListLock.EnterWriteLock();
                _chunkList = ((ChunkListUpdate)message.Data).ChunkList;
                _chunkListLock.ExitWriteLock();
                SendMessage(new Message(message, new Acknowledgement(), false));
            }
        }
Ejemplo n.º 49
0
 public void Check(UserContext ctx, DataOperation op)
 {
     if (!TryCheck(ctx, op))
     {
         throw new AccessDeniedException();
     }
 }
Ejemplo n.º 50
0
 public static Task TraceIfEnabledAsync(this ITraceWriter traceWriter, string data, DataOperation operation)
 {
     if (traceWriter == null || !traceWriter.IsEnabled)
     {
         return(TaskUtil.CompletedTask);
     }
     return(traceWriter.TraceAsync(data, operation));
 }
Ejemplo n.º 51
0
 public ACLAccountId(int value, DataOperation op)
     : this(value, (int)op, DataOperationPermission.Allow)
 {
 }
 /// <summary>
 /// 谁的那个
 /// </summary>
 /// <param name="_Settings"></param>
 /// <param name="filter"></param>
 public QCCEnterpriseCrawler_FOSHAN(CrawlSettings _Settings, BloomFilter <string> _filter, DataOperation _dataop)
 {
     Settings = _Settings; filter = _filter; dataop = _dataop;
 }
Ejemplo n.º 53
0
        public override ACLVerdict Apply(UserContext ctx, DataOperation op)
        {
            if ((op == DataOperation.Create || op == DataOperation.Delete) && ctx.AccountId != 0)
            {
                return ACLVerdict.Allowed;
            }

            return ACLVerdict.None;
        }
Ejemplo n.º 54
0
 /// <summary>
 ///存款
 /// </summary>
 public override void Diposit(string genType, double money)
 {
     base.Diposit("存款", money);
     //结算利息
     base.Diposit("结息", DataOperation.GetRate(RateType.零存整取3年) * money);
 }
Ejemplo n.º 55
0
 public ACLBaseEntry(DataOperation op)
     : this(op, DataOperationPermission.Allow)
 {
 }
Ejemplo n.º 56
0
        public override void OnEnter(GameState previousState)
        {
            if (!Directory.Exists(Settings.SettingsDirectory + "/maps"))
            {
                // creates directories recursively
                Directory.CreateDirectory(Settings.SettingsDirectory + "/maps");
            }

            Game.IsMouseVisible = true;
            if (previousState is WorldState)
            {
                Map = (previousState as WorldState).Map;
            }
            else
            {
                Map = new Map(50, 50, new Map.Information("Untitled", Map.Environment.Forest, Map.Weather.Sunny));
            }

            if (Map.TransitionCache != null)
            {
                Map.TransitionCache.Clear();
            }
            if (Map.Atlas != null)
            {
                Map.Atlas.Clear();
            }

            Camera = new Camera(this);

            Buttons.Add("edit-tiles-mode", new Button
            {
                Text     = "",
                Icon     = Assets.Get <Texture2D>("editor/tiles.png"),
                Position = new TweenedVector2(Game, new Vector2(-200, 114)),
                Font     = Game.DefaultFonts.Normal,
                Clicked  = (btn) =>
                {
                    MapEditorTileEditState state = new MapEditorTileEditState();
                    if (CurrentState is MapEditorEditAttributesState)
                    {
                        state.Layer = (CurrentState as MapEditorEditAttributesState).Layer;
                    }

                    CurrentState = state;
                },

                Active = false
            });

            Buttons.Add("edit-attributes-mode", new Button
            {
                Text     = "",
                Icon     = Assets.Get <Texture2D>("editor/attributes.png"),
                Position = new TweenedVector2(Game, new Vector2(-200, 114 + 32)),
                Font     = Game.DefaultFonts.Normal,
                Clicked  = (btn) =>
                {
                    MapEditorEditAttributesState state = new MapEditorEditAttributesState();
                    if (CurrentState is MapEditorTileEditState)
                    {
                        state.Layer = (CurrentState as MapEditorTileEditState).Layer;
                    }

                    CurrentState = state;
                },

                Active = false
            });

            Buttons.Add("edit-info-mode", new Button
            {
                Text     = "",
                Icon     = Assets.Get <Texture2D>("editor/info.png"),
                Position = new TweenedVector2(Game, new Vector2(-200, 114 + 32 * 2)),
                Font     = Game.DefaultFonts.Normal,
                Clicked  = (btn) =>
                {
                    CurrentState = new MapEditorEditInfoState();
                },

                Active = false
            });

            Buttons.Add("keybinds-help-mode", new Button
            {
                Text     = "",
                Icon     = Assets.Get <Texture2D>("editor/keybinds.png"),
                Position = new TweenedVector2(Game, new Vector2(-200, 114 + 32 * 3)),
                Font     = Game.DefaultFonts.Normal,
                Clicked  = (btn) =>
                {
                    CurrentState = new MapEditorShowKeybindsState();
                },

                Active = false
            });

            Buttons.Add("player-view-mode", new Button
            {
                Text     = "",
                Icon     = Assets.Get <Texture2D>("editor/player.png"),
                Position = new TweenedVector2(Game, new Vector2(-200, 114 + 32 * 4)),
                Font     = Game.DefaultFonts.Normal,
                Clicked  = (btn) =>
                {
                    CurrentState = new MapEditorPlayerViewState();
                },

                Active = false
            });

            Buttons.Add("playtest", new Button
            {
                Text     = "",
                Icon     = Assets.Get <Texture2D>("editor/arrow.png"),
                Position = new TweenedVector2(Game, new Vector2(-200, 118 + 32 * 5)),
                Font     = Game.DefaultFonts.Normal,
                Clicked  = (btn) =>
                {
                    _doPlaytest = true;
                },

                Active = false
            });

            Buttons.Add("load", new Button
            {
                Text     = "",
                Icon     = Assets.Get <Texture2D>("editor/load.png"),
                Position = new TweenedVector2(Game, new Vector2(-200, 118 + 32 * 6)),
                Font     = Game.DefaultFonts.Normal,
                Clicked  = (btn) =>
                {
                    OpenFileDialog dialog = new OpenFileDialog();

                    dialog.Filter           = "Map files (*.json)|*.json|All files (*.*)|*.*";
                    dialog.RestoreDirectory = true;
                    dialog.InitialDirectory = Settings.SettingsDirectory + Path.DirectorySeparatorChar + "maps";
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        _dataOperation = DataOperation.Loading;
                        Task.Run(() =>
                        {
                            Map            = Map.Load(dialog.FileName);
                            _dataOperation = DataOperation.None;
                        });
                    }

                    dialog.Dispose();
                    Application.DoEvents();
                },

                Active = false
            });

            Buttons.Add("save", new Button
            {
                Text     = "",
                Icon     = Assets.Get <Texture2D>("editor/save.png"),
                Position = new TweenedVector2(Game, new Vector2(-200, 118 + 32 * 7)),
                Font     = Game.DefaultFonts.Normal,
                Clicked  = (btn) =>
                {
                    SaveFileDialog dialog = new SaveFileDialog();

                    dialog.Filter           = "Map files (*.json)|*.json|All files (*.*)|*.*";
                    dialog.RestoreDirectory = true;
                    dialog.InitialDirectory = Settings.SettingsDirectory + Path.DirectorySeparatorChar + "maps";
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        _dataOperation = DataOperation.Saving;
                        Task.Run(() => {
                            Map.Save(new FileStream(dialog.FileName, FileMode.Create));
                            _dataOperation = DataOperation.None;
                        });
                    }

                    dialog.Dispose();
                    Application.DoEvents();
                },

                Active = false
            });

            Buttons.Add("exit", new Button
            {
                Text     = "",
                Icon     = Assets.Get <Texture2D>("editor/exit.png"),
                Position = new TweenedVector2(Game, new Vector2(-200, 118 + 32 * 8)),
                Font     = Game.DefaultFonts.Normal,
                Clicked  = (btn) => { _exiting = true; },

                Active = false
            });

            Buttons["edit-tiles-mode"].Position.TweenTo(new Vector2(10, 114), TweenEaseType.EaseOutQuad, 0.65f);
            Buttons["edit-attributes-mode"].Position.TweenTo(new Vector2(10, 114 + 32), TweenEaseType.EaseOutQuad, 0.65f);
            Buttons["edit-info-mode"].Position.TweenTo(new Vector2(10, 114 + 32 * 2), TweenEaseType.EaseOutQuad, 0.65f);
            Buttons["keybinds-help-mode"].Position.TweenTo(new Vector2(10, 114 + 32 * 3), TweenEaseType.EaseOutQuad, 0.65f);
            Buttons["player-view-mode"].Position.TweenTo(new Vector2(10, 114 + 32 * 4), TweenEaseType.EaseOutQuad, 0.65f);

            Buttons["playtest"].Position.TweenTo(new Vector2(10, 118 + 32 * 5), TweenEaseType.EaseOutQuad, 0.65f);
            Buttons["load"].Position.TweenTo(new Vector2(10, 118 + 32 * 6), TweenEaseType.EaseOutQuad, 0.65f);
            Buttons["save"].Position.TweenTo(new Vector2(10, 118 + 32 * 7), TweenEaseType.EaseOutQuad, 0.65f);
            Buttons["exit"].Position.TweenTo(new Vector2(10, 118 + 32 * 8), TweenEaseType.EaseOutQuad, 0.65f);

            _topTextY = new TweenedDouble(Game, -300);
            _topTextY.TweenTo(10, TweenEaseType.EaseOutQuad, 0.65f);

            _fade = new TweenedDouble(Game, 1.0);
            _fade.TweenTo(0, TweenEaseType.Linear, 0.5f);

            _topTextFade = new TweenedDouble(Game, 2.0);

            CurrentState = new MapEditorTileEditState();
        }
Ejemplo n.º 57
0
 public abstract ACLVerdict Apply(UserContext ctx, DataOperation op);
Ejemplo n.º 58
0
        ///// <summary>
        /////  分类信息
        ///// </summary>
        //public string DataTableNameCategory
        //{
        //    get { return "CategoryInfo_MT"; }

        //}

        /// <summary>
        ///  构造函数
        /// </summary>
        /// <param name="_Settings"></param>
        /// <param name="filter"></param>
        public HuiCongMaterialAPPCrawler(CrawlSettings _Settings, BloomFilter <string> _filter, DataOperation _dataop)
        {
            Settings   = _Settings; filter = _filter; dataop = _dataop;
            guidFilter = new BloomFilter <string>(9000000);
        }
Ejemplo n.º 59
0
        public ACLVerdict Apply(UserContext ctx, DataOperation op)
        {
            ACLVerdict current = ACLVerdict.Denied;

            foreach (IACLEntry entry in _accessControlList)
            {
                ACLVerdict result = entry.Apply(ctx, op);
                switch (result)
                {
                    case ACLVerdict.Denied:
                        return ACLVerdict.Denied;
                    case ACLVerdict.Allowed:
                        current = ACLVerdict.Allowed;
                        break;
                }
            }

            return current;
        }
Ejemplo n.º 60
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public CommonSearch()
 {
     dataOp = new DataOperation();
 }