Exemplo n.º 1
0
        /// <summary>
        /// 获取退回某步列表
        /// </summary>
        /// <param name="StepID"></param>
        /// <returns></returns>
        private JObject GetReturnStepsForm(BPMConnection cn, string UserAccount, int StepID)
        {
            JObject           rv    = new JObject();//最终组合的
            BPMStepCollection steps = null;

            steps = BPMProcStep.GetRecedableToSteps(cn, StepID);
            //将数据转化为Json集合
            rv["totalRows"] = steps.Count;
            if (steps.Count < 1)
            {
                throw new Exception("StepID:" + StepID + "帐号:" + UserAccount + "无退回步骤");
            }

            JArray children = new JArray();

            rv["children"] = children;

            foreach (BPMProcStep step in steps)
            {
                JObject item = new JObject();
                children.Add(item);

                item["StepID"]           = step.StepID;
                item["NodeName"]         = step.NodeName;
                item["OwnerAccount"]     = step.OwnerAccount;
                item["OwnerDisplayName"] = step.OwnerFullName;
                item["FinishAt"]         = YZStringHelper.DateToStringL(step.FinishAt);
            }
            return(rv);
        }
Exemplo n.º 2
0
        protected virtual JObject JObjectFromMember(Member member, User user)
        {
            JObject item = new JObject();

            item["Account"]        = user.Account;
            item["SID"]            = user.SID;
            item["DisplayName"]    = user.DisplayName;
            item["MemberFullName"] = member.FullName;
            item["LeaderTitle"]    = member.LeaderTitle;
            item["Department"]     = member.Department;
            item["Description"]    = user.Description;
            item["Sex"]            = user.Sex == Sex.Unknown ? "":user.Sex.ToString();
            item["Birthday"]       = YZStringHelper.DateToStringL(user.Birthday);
            item["HRID"]           = user.HRID;
            item["DateHired"]      = YZStringHelper.DateToStringL(user.DateHired);
            item["Office"]         = user.Office;
            item["CostCenter"]     = user.CostCenter;
            item["OfficePhone"]    = user.OfficePhone;
            item["HomePhone"]      = user.HomePhone;
            item["Mobile"]         = user.Mobile;
            item["EMail"]          = user.EMail;
            item["WWWHomePage"]    = user.WWWHomePage;
            item["ShortName"]      = user.ShortName;
            item["FriendlyName"]   = user.FriendlyName;

            foreach (string attrName in user.ExtAttrNames)
            {
                item[attrName] = Convert.ToString(user[attrName]);
            }

            item["User"]   = JObject.FromObject(user);
            item["Member"] = JObject.FromObject(member);

            return(item);
        }
Exemplo n.º 3
0
        protected virtual string FormatValue(object value)
        {
            string strValue;

            if (value == null)
            {
                strValue = String.Empty;
            }
            else
            {
                if (value is DateTime)
                {
                    strValue = YZStringHelper.DateToStringL((DateTime)value);
                }
                else if (value is byte[])
                {
                    strValue = Convert.ToBase64String((byte[])value);
                }
                else
                {
                    strValue = value.ToString();
                }
            }

            return(strValue);
        }
Exemplo n.º 4
0
 public virtual string GenPeriodCond(string fieldName, DateTime date1, DateTime date2)
 {
     return(String.Format("({0}>='{1}' AND {0}<'{2}')",
                          fieldName,
                          YZStringHelper.DateToStringL(date1),
                          YZStringHelper.DateToStringL(date2)));
 }
Exemplo n.º 5
0
 public JsonItem(AttachmentInfo attachment)
 {
     this.Attributes["FileID"]       = attachment.FileID;
     this.Attributes["Name"]         = attachment.Name;
     this.Attributes["Ext"]          = attachment.Ext;
     this.Attributes["Size"]         = attachment.Size;
     this.Attributes["LastUpdate"]   = YZStringHelper.DateToStringL(attachment.LastUpdate);
     this.Attributes["OwnerAccount"] = attachment.OwnerAccount;
 }
Exemplo n.º 6
0
        protected static object DateYMDHMS(string fieldXClass, object value)
        {
            if (value is DateTime && fieldXClass != "Ext.field.DatePicker")
            {
                return(YZStringHelper.DateToStringL((DateTime)value));
            }

            return(value);
        }
Exemplo n.º 7
0
        protected virtual void ApplyExcelData(YZRequest request, JObject rv, ReportExcelView view, DataTable dataTable, YZClientParamCollection queryParams)
        {
            string excelTemplate = request.Context.Server.MapPath("~/YZSoft/Report/Templates/" + view.TemplateFile);
            Dictionary <string, string> reportParams = new Dictionary <string, string>();

            reportParams.Add("ReportDate", YZStringHelper.DateToStringL(DateTime.Today));
            foreach (YZClientParam queryParam in queryParams)
            {
                reportParams.Add(queryParam.name, Convert.ToString(queryParam.value));
            }

            dataTable.TableName = "GridStore";

            //打开文件
            HSSFWorkbook book;

            using (FileStream file = new FileStream(excelTemplate, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                book = new HSSFWorkbook(file);
            }

            //填充数据
            DataSet dataset = new DataSet();

            dataset.Tables.Add(dataTable);
            YZExcelGenerate.Fill(book, reportParams, dataset);
            YZExcelGenerate.PrepareForOutput(book);

            //调试输出
            //using (FileStream fs = new FileStream(@"e:\abc.xls", FileMode.Create))
            //{
            //    book.Write(fs);
            //    fs.Close();
            //}

            book.GetSheetAt(0).DisplayGridlines = false;

            using (MemoryStream stream = new MemoryStream())
            {
                book.Write(stream);

                string htmlFile = FileConvert.Excel2Html(stream, Path.GetExtension(excelTemplate));
                rv["htmlFile"] = Path.GetFileName(htmlFile);
            }
        }
Exemplo n.º 8
0
        private JObject MyTask(BPMConnection cn, string Path, int Start, int Limit, string ProcessName, string Keyword)
        {
            int     rowcount;
            JObject result              = new JObject();
            string  TaskFilter          = getTaskFilter(ProcessName, Keyword, true);
            BPMTaskListCollection tasks = cn.GetMyTaskList(Path, TaskFilter, "StepID DESC", Start, Limit, out rowcount);

            //将数据转化为Json集合
            result["success"]   = true;
            result["totalRows"] = rowcount;

            JArray children = new JArray();

            result["children"] = children;
            foreach (BPMTaskListItem task in tasks)
            {
                JObject item = new JObject();
                children.Add(item);

                item["StepID"]       = task.StepID;
                item["TaskID"]       = task.TaskID;
                item["SerialNum"]    = task.SerialNum;
                item["ProcessName"]  = task.ProcessName;
                item["OwnerAccount"] = task.OwnerAccount;
                item["OwnerName"]    = task.OwnerFullName;
                item["AgentAccount"] = task.AgentAccount == null ? "" : task.AgentAccount;
                item["AgentName"]    = task.AgentFullName == null ? "" : task.AgentFullName;
                item["CreateAt"]     = YZStringHelper.DateToStringL(task.CreateAt);
                item["NodeName"]     = task.StepName;
                item["ReceiveAt"]    = YZStringHelper.DateToStringL(task.ReceiveAt);
                item["Share"]        = task.Share;
                item["Description"]  = task.Description == null ? "" : task.Description;
            }

            //这里发现一个系统bug,当Start为1时,实际第1条待办也会在结果里,导致实际的数量比Limit多1条。
            if (Start == 1 && children.Count - Limit == 1)
            {
                children.RemoveAt(0);
            }

            return(result);
        }
Exemplo n.º 9
0
        private JObject GetApprovalLog(BPMConnection cn, int TaskID)
        {
            JObject result = new JObject();

            BPMTask task = BPMTask.Load(cn, TaskID);

            result["success"] = true;
            result["TaskID"]  = TaskID;
            result["SN"]      = task.SerialNum;
            result["State"]   = task.TaskState.ToString();

            JArray StepItems = new JArray();

            result["StepItems"] = StepItems;

            BPMStepCollection steps = BPMTask.GetAllSteps(cn, TaskID);

            foreach (BPMProcStep step in steps)
            {
                if (step.IsHumanStep)
                {
                    JObject item = new JObject();
                    StepItems.Add(item);
                    item["StepID"]           = step.StepID;
                    item["NodeName"]         = step.NodeName;
                    item["ReceiveAt"]        = YZStringHelper.DateToStringL(step.ReceiveAt);
                    item["FinishAt"]         = step.FinishAt == DateTime.MinValue ? "" : YZStringHelper.DateToStringL(step.FinishAt);
                    item["OwnerAccount"]     = step.OwnerAccount;
                    item["OwnerName"]        = step.OwnerFullName;
                    item["RecipientAccount"] = step.RecipientAccount == null ? "" : step.RecipientAccount;
                    item["RecipientName"]    = step.RecipientFullName == null ? "" : step.RecipientFullName;
                    item["HandlerAccount"]   = step.HandlerAccount == null ? "" : step.HandlerAccount;
                    item["HandlerName"]      = step.HandlerFullName == null ? "" : step.HandlerFullName;
                    item["AgentAccount"]     = step.AgentAccount == null ? "" : step.AgentAccount;
                    item["AgentName"]        = step.AgentFullName == null ? "" : step.AgentFullName;
                    item["SelAction"]        = step.SelAction == null ? "" : step.SelAction;
                    item["Comments"]         = step.Comments == null ? "" : step.Comments;
                }
            }

            return(result);
        }
Exemplo n.º 10
0
        public virtual JObject GetSimulateForm(HttpContext context)
        {
            YZRequest request     = new YZRequest(context);
            string    processName = request.GetString("processName");
            Version   version     = request.GetVersion("version");
            string    uid         = request.GetString("uid");

            BPMProcStep           step;
            BPMTask               task;
            MobileFormSetting     formSetting;
            FlowDataSet           formdataset;
            CommentItemCollection comments;

            User user;

            YZAuthHelper.SetAuthCookie(uid);
            try
            {
                using (BPMConnection cn = new BPMConnection())
                {
                    cn.WebOpen();
                    TableIdentityCollection tableIdentities = BPMProcess.GetProcessGlobalTableIdentitys(cn, processName, version);
                    formdataset = DataSourceManager.LoadDataSetSchema(cn, tableIdentities);
                    user        = User.TryGetUser(cn, uid);
                    if (user == null)
                    {
                        user             = new User();
                        user.Account     = uid;
                        user.DisplayName = "张三";
                    }
                }
            }
            catch (Exception e)
            {
                YZAuthHelper.ClearAuthCookie();
                throw e;
            }

            task = this.GetSimulateTask(user, processName, version);
            step = this.GetSimulateStep(task, user);

            JObject post = request.GetPostData <JObject>();

            if (post != null)
            {
                formSetting = post.ToObject <MobileFormSetting>();
            }
            else
            {
                formSetting = new MobileFormSetting();
            }

            comments = new CommentItemCollection();

            for (int i = 0; i < formdataset.Tables.Count; i++)
            {
                FlowDataTable table = formdataset.Tables[i];
                if (!table.IsRepeatableTable)
                {
                    table.Rows.Add(this.CreateNewRow(table, i, 0));
                }
                else
                {
                    table.Rows.Add(this.CreateNewRow(table, i, 0));
                    table.Rows.Add(this.CreateNewRow(table, i, 1));
                }
            }

            //附件的演示数据会导致错误(附件ID没有),必须处理(将附件数据置空)
            foreach (FlowDataTable table in formSetting.ControlDataSet.Tables)
            {
                FlowDataTable dataTable = formdataset.Tables.TryGetTable(table.TableName);
                if (dataTable != null)
                {
                    foreach (FlowDataColumn column in table.Columns)
                    {
                        if (column.MapTo == "YZSoft$ux.field.Attachment")
                        {
                            foreach (FlowDataRow row in dataTable.Rows)
                            {
                                row[column.ColumnName] = ""; //不能设置null,设置null附件控件表现形式不同
                            }
                        }
                    }
                }
            }

            this.ParseMobileFormSetting(formSetting);

            //准备返回值
            JObject result = new JObject();

            //填充form域(表单信息)
            JObject fieldset;
            JArray  items;
            JObject field;

            JObject form = new JObject();

            result["form"] = form;

            JArray formitems = new JArray();

            form["items"] = formitems;

            //基本信息的fieldset填充
            fieldset = new JObject();
            formitems.Add(fieldset);
            fieldset["xtype"]     = "fieldset";
            fieldset["innerName"] = "Header";

            //fieldset["title", "基本信息");
            items             = new JArray();
            fieldset["items"] = items;

            field = new JObject();
            items.Add(field);
            field["xclass"]  = "YZSoft.form.FormHeader";
            field["padding"] = "16 10 10 16";
            field["task"]    = this.Serialize(task);

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Field";
            field["label"]  = Resources.YZMobile.Aspx_FormData_StepName;
            field["html"]   = step.StepDisplayName;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Field";
            field["label"]  = Resources.YZMobile.Aspx_FormData_Date;
            field["html"]   = YZStringHelper.DateToStringL(task.CreateAt);

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Field";
            field["label"]  = Resources.YZMobile.Aspx_FormData_Desc;
            field["html"]   = task.Description;

            //应用移动表单设定字段 - 非可重复表
            this.ApplyMasterFields(Model.Process, form, formitems, task, step, formSetting, formdataset);

            //应用移动表单设定字段 - 可重复表
            this.ApplyDetailFields(Model.Process, form, formitems, task, step, formSetting, formdataset);

            //自定义信息
            this.ApplyCustomFields(Model.Process, form, formitems, task, step, formdataset, comments);

            //控件测试
            //this.AddTestingFields(Model.Process, form, formitems, task, step, formdataset, comments);

            return(result);
        }
Exemplo n.º 11
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.AppendHeader("Access-Control-Allow-Origin", "*");      // 响应类型
                context.Response.AppendHeader("Access-Control-Allow-Methods", "POST");  // 响应头设置
                context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

                context.Response.Charset         = "gb2312"; //设置字符集类型
                context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                context.Response.ContentType     = "application/json;charset=gb2312";

                //context.Response.ContentType = "text/json";

                string account   = context.Request.Params["UserAccount"];
                string token     = context.Request.Params["Token"];
                string thumbnail = context.Request.Params["thumbnail"];


                YZAuthHelper.OAuth();
                //YZAuthHelper.AshxAuthCheck();


                //if (!YZAuthHelper.IsAuthenticated)
                //{
                //    JsonItem rv = new JsonItem();
                //    rv.Attributes["success"] = false;
                //    rv.Attributes["errorMessage"] = JosonStrings.Aspx_Upload_NoAuth;
                //    context.Response.Write(rv.ToString());
                //    return;
                //}


                HttpFileCollection files = context.Request.Files;
                if (files.Count > 0 && files[0].ContentLength > 0)
                {
                    HttpPostedFile file     = files[0];
                    string         fileName = System.IO.Path.GetFileName(file.FileName);
                    long           fileSize = file.ContentLength;
                    string         fileExt  = System.IO.Path.GetExtension(fileName).ToLower();

                    string fileId;
                    string savePath;
                    do
                    {
                        fileId   = YZAttachmentHelper.GetNewFileID();
                        savePath = Attachment.FileIDToPath(fileId, YZAttachmentHelper.AttachmentRootPath);
                    } while (File.Exists(savePath));

                    Directory.CreateDirectory(savePath.Substring(0, savePath.LastIndexOf(@"\")));
                    file.SaveAs(savePath);

                    if (!String.IsNullOrEmpty(thumbnail) && !YZStringHelper.EquName(thumbnail, "n"))
                    {
                        this.MakeThumbnail(savePath, "S");
                        this.MakeThumbnail(savePath, "M");
                    }

                    Attachment attachment = new Attachment();
                    attachment.FileID       = fileId;
                    attachment.Name         = fileName;
                    attachment.Ext          = fileExt;
                    attachment.Size         = fileSize;
                    attachment.LastUpdate   = DateTime.Now;
                    attachment.OwnerAccount = YZAuthHelper.LoginUserAccount;

                    using (IDbConnection cn = YZDBProviderManager.CurrentProvider.OpenConnection())
                    {
                        YZDBProviderManager.CurrentProvider.InsertAttachmentInfo(cn, attachment);
                    }

                    JsonItem rv = new JsonItem();

                    rv.Attributes["success"] = true;
                    rv.Attributes["fileid"]  = fileId;
                    rv.Attributes["Name"]    = fileName;
                    rv.Attributes["Ext"]     = fileExt;

                    rv.Attributes["Size"]         = fileSize;
                    rv.Attributes["OwnerAccount"] = attachment.OwnerAccount;
                    rv.Attributes["LastUpdate"]   = YZStringHelper.DateToStringL(attachment.LastUpdate);


                    context.Response.Write(rv.ToString());
                }
                else
                {
                    JsonItem rv = new JsonItem();
                    rv.Attributes["success"]      = false;
                    rv.Attributes["errorMessage"] = JosonStrings.Aspx_Invalid_File;

                    context.Response.Write(rv.ToString());
                }
            }
            catch (Exception exp)
            {
                JsonItem rv = new JsonItem();
                rv.Attributes["success"]      = false;
                rv.Attributes["errorMessage"] = exp.Message /* + exp.StackTrace*/;
                context.Response.Write(rv.ToString());
            }
        }
Exemplo n.º 12
0
 //日期
 public override string DateToQueryString(DateTime date)
 {
     return("'" + YZStringHelper.DateToStringL(date) + "'");
 }
Exemplo n.º 13
0
    public static HSSFWorkbook NoTemplateExport(ColumnDefineCollection columnDefines, DataTable table)
    {
        //创建工作簿
        HSSFWorkbook book = new HSSFWorkbook();

        //增加标题Style
        HSSFCellStyle styleHeader = (HSSFCellStyle)book.CreateCellStyle();

        styleHeader.FillForegroundColor = HSSFColor.BLUE.index;
        styleHeader.FillPattern         = FillPatternType.SOLID_FOREGROUND;

        //设置Font
        HSSFFont fontHeader = (HSSFFont)book.CreateFont();

        fontHeader.FontName   = "Tahoma";
        fontHeader.FontHeight = 200;
        fontHeader.Color      = HSSFColor.WHITE.index;
        styleHeader.SetFont(fontHeader);

        //设置缺省Style
        HSSFCellStyle styleDefault = (HSSFCellStyle)book.CreateCellStyle();
        HSSFFont      fontDefault  = (HSSFFont)book.CreateFont();

        styleDefault.SetFont(fontDefault);
        fontDefault.FontName   = "Tahoma";
        fontDefault.FontHeight = 200;

        //创建Sheet
        HSSFRow   row;
        HSSFCell  cell;
        HSSFSheet sheet = (HSSFSheet)book.CreateSheet("Sheet1");

        //创建标题列
        row = (HSSFRow)sheet.CreateRow(0);
        for (int i = 0; i < columnDefines.Count; i++)
        {
            ColumnDefine columnDefine = columnDefines[i];

            //创建cell
            cell = (HSSFCell)row.CreateCell(i, CellType.STRING);

            //应用style
            HSSFCellStyle style = (HSSFCellStyle)book.CreateCellStyle();
            style.CloneStyleFrom(styleHeader);
            style.Alignment = columnDefine.Align;
            cell.CellStyle  = style;

            //设置值
            cell.SetCellValue(columnDefine.Text);

            sheet.SetColumnWidth(i, YZExcelHelper.PixelToExcel(columnDefine.Width));
        }

        foreach (DataRow dataRow in table.Rows)
        {
            row = (HSSFRow)sheet.CreateRow(sheet.LastRowNum + 1);
            for (int i = 0; i < columnDefines.Count; i++)
            {
                ColumnDefine columnDefine = columnDefines[i];
                object       objValue     = dataRow[columnDefine.ColumnName];

                //SQL Server数据库中monery4位小数点处理
                if (objValue is decimal)
                {
                    objValue = (decimal)Decimal.ToDouble((decimal)objValue);
                }

                //创建cell
                cell = (HSSFCell)row.CreateCell(i, CellType.STRING);

                //应用style
                if (columnDefine.Style == null)
                {
                    columnDefine.Style = (HSSFCellStyle)book.CreateCellStyle();
                    columnDefine.Style.CloneStyleFrom(styleDefault);
                    columnDefine.Style.Alignment = columnDefine.Align;
                }
                cell.CellStyle = columnDefine.Style;

                //设置值
                TypeCode typeCode = Type.GetTypeCode(objValue == null ? typeof(string) : objValue.GetType());
                switch (typeCode)
                {
                case TypeCode.Boolean:
                    cell.SetCellValue(Convert.ToBoolean(objValue));
                    break;

                case TypeCode.DateTime:
                    DateTime date     = (DateTime)objValue;
                    string   strValue = date == DateTime.MinValue ? "" : YZStringHelper.DateToStringL(date);
                    cell.SetCellValue(strValue);
                    break;

                case TypeCode.Decimal:
                case TypeCode.Double:
                case TypeCode.Int16:
                case TypeCode.Int32:
                case TypeCode.Int64:
                case TypeCode.Single:
                case TypeCode.UInt16:
                case TypeCode.UInt32:
                case TypeCode.UInt64:
                case TypeCode.SByte:
                case TypeCode.Byte:
                    cell.SetCellValue(Convert.ToDouble(objValue));
                    break;

                default:
                    cell.SetCellValue(Convert.ToString(objValue));
                    break;
                }
            }
        }

        return(book);
    }
Exemplo n.º 14
0
 public static string DateToStringL(DateTime date)
 {
     return(YZStringHelper.DateToStringL(date, null));
 }
Exemplo n.º 15
0
 //日期
 public override string DateToQueryString(DateTime date)
 {
     return(String.Format("TO_DATE('{0}','YYYY-MM-DD HH24:MI:SS')", YZStringHelper.DateToStringL(date)));
 }
Exemplo n.º 16
0
        public void ProcessRequest(HttpContext context)
        {
            YZAuthHelper.OAuth();

            //YZAuthHelper.AshxAuthCheck();

            //GridPageInfo gridPageInfo = new GridPageInfo(context);
            //IDBProvider dbProvider = YZDBProviderManager.CurrentProvider;

            int Mouth;

            if (context.Request.Params["byMouth"] == "1")
            {
                Mouth = 0;
            }
            else
            {
                string strMouth = context.Request.Params["Mouth"];
                Mouth = String.IsNullOrEmpty(strMouth) ? DateTime.Today.Month : Convert.ToInt32(strMouth);
            }

            //获得数据
            BPMTaskCollection tasks = new BPMTaskCollection();
            int      rowcount       = 0;
            JsonItem rootItem       = new JsonItem();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                String UserAccount = context.Request.Params["UserAccount"];

                //User user = User.FromAccount(cn, UserID);

                //YZAuthHelper.SetAuthCookie(realAccount);
                //YZAuthHelper.GetCookie();

                DataTable Dt = new SqlServerProvider(context).getWorkTimesLog(UserAccount, Mouth);

                //将数据转化为Json集合
                rootItem.Attributes.Add(JsonItem.TotalRows, rowcount);

                JsonItemCollection children = new JsonItemCollection();
                rootItem.Attributes.Add("children", children);
                rootItem.Attributes.Add("total", Dt.Rows.Count);

                int index = 0;
                foreach (DataRow Dr in Dt.Rows)
                {
                    JsonItem item = new JsonItem();
                    children.Add(item);


                    String StartTime = String.IsNullOrEmpty(Convert.ToString(Dr["StartTime"])) ? null : Convert.ToString(Dr["StartTime"]);
                    String EndTime   = String.IsNullOrEmpty(Convert.ToString(Dr["EndTime"])) ? null : Convert.ToString(Dr["EndTime"]);


                    item.Attributes.Add("ID", index);
                    item.Attributes.Add("EmpID", Dr["EmpID"].ToString());
                    item.Attributes.Add("WorkDay", Dr["WorkDay"].ToString());
                    item.Attributes.Add("WeekInt", Dr["WeekInt"].ToString());
                    item.Attributes.Add("ClassID", Dr["ClassID"].ToString());
                    item.Attributes.Add("StartTime", YZStringHelper.DateToStringL(Convert.ToDateTime(StartTime)));
                    item.Attributes.Add("EndTime", YZStringHelper.DateToStringL(Convert.ToDateTime(EndTime)));
                    item.Attributes.Add("NotCard", Convert.ToString(Dr["NotCard"]));
                    item.Attributes.Add("GongGan", Convert.ToString(Dr["GongGan"]));

                    item.Attributes.Add("V1", Convert.ToString(Dr["V1"]));
                    item.Attributes.Add("V2", Convert.ToString(Dr["V2"]));
                    item.Attributes.Add("V3", Convert.ToString(Dr["V3"]));
                    item.Attributes.Add("V4", Convert.ToString(Dr["V4"]));
                    item.Attributes.Add("V5", Convert.ToString(Dr["V5"]));
                    item.Attributes.Add("V6", Convert.ToString(Dr["V6"]));

                    item.Attributes.Add("HDay", Convert.ToString(Dr["HDay"]).Split(',')[0].Replace(" ", ""));
                    item.Attributes.Add("Holiday", Convert.ToString(Dr["Holiday"]));

                    item.Attributes.Add("OverTime_H", Convert.ToString(Dr["OverTime_H"]));
                    item.Attributes.Add("OverTime_W", Convert.ToString(Dr["OverTime_W"]));
                    item.Attributes.Add("OverTime", Convert.ToString(Dr["OverTime"]));



                    //item.Attributes.Add("UserShortName", YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName));

                    index++;
                }
            }

            //System.Threading.Thread.Sleep(500);
            context.Response.AppendHeader("Access-Control-Allow-Origin", "*");      // 响应类型
            context.Response.AppendHeader("Access-Control-Allow-Methods", "POST");  // 响应头设置
            context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

            context.Response.Charset         = "gb2312"; //设置字符集类型
            context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            context.Response.ContentType     = "application/json;charset=gb2312";
            //输出数据
            context.Response.Write(rootItem.ToString());
        }
Exemplo n.º 17
0
        public void ProcessRequest(HttpContext context)
        {
            YZAuthHelper.OAuth();

            //YZAuthHelper.AshxAuthCheck();

            GridPageInfo gridPageInfo = new GridPageInfo(context);
            IDBProvider  dbProvider   = YZDBProviderManager.CurrentProvider;

            //获得数据
            BPMTaskListCollection tasks = new BPMTaskListCollection();
            int      rowcount;
            JsonItem rootItem = new JsonItem();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                tasks = cn.GetMyTaskList(dbProvider.FilterStringMyTask, null, gridPageInfo.Start, gridPageInfo.Limit, out rowcount);

                //将数据转化为Json集合
                rootItem.Attributes.Add(JsonItem.TotalRows, rowcount);
                rootItem.Attributes.Add("total", rowcount);

                JsonItemCollection children = new JsonItemCollection();
                rootItem.Attributes.Add("children", children);


                foreach (BPMTaskListItem task in tasks)
                {
                    JsonItem item = new JsonItem();
                    children.Add(item);


                    //string OwnerDisplayName = (YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName) + task.ProcessName).Length>4
                    //    ? YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName).CutStrHTML(2)
                    //    : YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName);

                    item.Attributes.Add("tid", task.TaskID);
                    item.Attributes.Add("pid", task.StepID);
                    item.Attributes.Add("sn", task.SerialNum);
                    item.Attributes.Add("pn", task.ProcessName);
                    item.Attributes.Add("stepName", string.Empty);
                    //item.Attributes.Add("stepName", BPMProcStep.GetStepDisplayName(task.StepName).CutStrHTML(4));

                    //item.Attributes.Add("user", OwnerDisplayName);
                    item.Attributes.Add("user", YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName));

                    //item.Attributes.Add("date", String.Empty);
                    item.Attributes.Add("date", YZStringHelper.DateToStringL(task.CreateAt));

                    task.Description = task.ShowDescByProcessName(true);

                    item.Attributes.Add("desc", String.IsNullOrEmpty(task.Description) ? "无内容摘要" : task.Description);

                    DateTime time = new DateTime();
                    time.ToUniversalTime();
                }
            }

            //System.Threading.Thread.Sleep(2000);
            context.Response.AppendHeader("Access-Control-Allow-Origin", "*");      // 响应类型
            context.Response.AppendHeader("Access-Control-Allow-Methods", "POST");  // 响应头设置
            context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

            context.Response.Charset         = "gb2312"; //设置字符集类型
            context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            context.Response.ContentType     = "application/json;charset=gb2312";
            //输出数据
            context.Response.Write(rootItem.ToString());
        }
Exemplo n.º 18
0
        public void ProcessRequest(HttpContext context)
        {
            YZAuthHelper.OAuth();

            //YZAuthHelper.AshxAuthCheck();

            GridPageInfo gridPageInfo = new GridPageInfo(context);
            IDBProvider  dbProvider   = YZDBProviderManager.CurrentProvider;

            int year;

            if (context.Request.Params["byYear"] == "0")
            {
                year = -1;
            }
            else
            {
                string strYear = context.Request.Params["Year"];
                year = String.IsNullOrEmpty(strYear) ? DateTime.Today.Year : Convert.ToInt32(strYear);
            }

            //获得数据
            BPMTaskCollection tasks = new BPMTaskCollection();
            int      rowcount;
            JsonItem rootItem = new JsonItem();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                tasks = cn.GetHistoryTasks(year, HistoryTaskType.AllAccessable, dbProvider.FilterStringHistoryTaskTaskTableFilter, dbProvider.FilterStringHistoryTaskStepTableFilter, null, gridPageInfo.Start, gridPageInfo.Limit, out rowcount);

                //将数据转化为Json集合
                rootItem.Attributes.Add(JsonItem.TotalRows, rowcount);

                JsonItemCollection children = new JsonItemCollection();
                rootItem.Attributes.Add("children", children);
                rootItem.Attributes.Add("total", rowcount);

                foreach (BPMTask task in tasks)
                {
                    JsonItem item = new JsonItem();
                    children.Add(item);

                    item.Attributes.Add("tid", task.TaskID);
                    item.Attributes.Add("pid", task.ParentStepID);
                    item.Attributes.Add("sn", task.SerialNum);
                    item.Attributes.Add("pn", task.ProcessName);
                    item.Attributes.Add("user", YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName));
                    item.Attributes.Add("state", task.TaskState.ToString());
                    item.Attributes.Add("stateText", YZStringHelper.GetTaskStateDisplayName(task.TaskState));
                    item.Attributes.Add("stateProcessing", YZStringHelper.GetTaskProcessingStatus(cn, task.TaskState, task.TaskID));
                    item.Attributes.Add("date", YZStringHelper.DateToStringL(task.CreateAt));


                    task.Description = task.ShowDescByProcessName(true);

                    item.Attributes.Add("desc", String.IsNullOrEmpty(task.Description) ? "无内容摘要" : task.Description);
                }
            }

            //System.Threading.Thread.Sleep(500);
            context.Response.AppendHeader("Access-Control-Allow-Origin", "*");      // 响应类型
            context.Response.AppendHeader("Access-Control-Allow-Methods", "POST");  // 响应头设置
            context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

            context.Response.Charset         = "gb2312"; //设置字符集类型
            context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            context.Response.ContentType     = "application/json;charset=gb2312";
            //输出数据
            context.Response.Write(rootItem.ToString());
        }
Exemplo n.º 19
0
        private JObject SaveAttachment(HttpContext context)
        {
            JObject result = new JObject();

            HttpFileCollection files = context.Request.Files;

            if (files.Count > 0 && files[0].ContentLength > 0)
            {
                HttpPostedFile file     = files[0];
                string         fileName = System.IO.Path.GetFileName(file.FileName);
                long           fileSize = file.ContentLength;
                string         fileExt  = System.IO.Path.GetExtension(fileName).ToLower();

                //华为手机,fileExt格式 .png?112714368714
                if (!String.IsNullOrEmpty(fileExt))
                {
                    int index = fileExt.IndexOf('?');
                    if (index != -1)
                    {
                        fileExt = fileExt.Substring(0, index);
                    }
                }

                string fileId   = YZAttachmentHelper.GetNewFileID();
                string savePath = Attachment.FileIDToPath(fileId, YZAttachmentHelper.AttachmentRootPath);

                Directory.CreateDirectory(savePath.Substring(0, savePath.LastIndexOf(@"\")));
                file.SaveAs(savePath);

                Attachment attachment = new Attachment();
                attachment.Name = fileName;
                attachment.Ext  = fileExt;
                attachment.Size = fileSize;

                attachment.FileID = fileId;
                if (String.IsNullOrEmpty(attachment.Name))
                {
                    attachment.Name = fileId + attachment.Ext;
                }

                attachment.LastUpdate   = DateTime.Now;
                attachment.OwnerAccount = YZAuthHelper.LoginUserAccount;

                using (IDbConnection cn = QueryManager.CurrentProvider.OpenConnection())
                {
                    QueryManager.CurrentProvider.InsertAttachmentInfo(cn, attachment);
                }

                result["success"] = true;
                result["fileid"]  = attachment.FileID;

                JObject attach = new JObject();
                result["attachment"]   = attach;
                attach["FileID"]       = attachment.FileID;
                attach["Name"]         = attachment.Name;
                attach["Ext"]          = attachment.Ext;
                attach["Size"]         = attachment.Size;
                attach["FileID"]       = attachment.FileID;
                attach["LastUpdate"]   = YZStringHelper.DateToStringL(attachment.LastUpdate);
                attach["OwnerAccount"] = attachment.OwnerAccount;
            }
            else
            {
                throw new Exception("未上传文件");
            }

            return(result);
        }
Exemplo n.º 20
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                YZAuthHelper.OAuth();
                //YZAuthHelper.AshxAuthCheck();

                string loginUid = YZAuthHelper.LoginUserAccount;

                IDBProvider dbProvider = YZDBProviderManager.CurrentProvider;

                string   method = context.Request.Params["method"];
                JsonItem rv     = new JsonItem();

                // System.Threading.Thread.Sleep(2000);

                if (method == "Send")
                {
                    //http://oauth.skyworthdigital.com/WebService/Iservice/Communication.ashx?UserAccount=SDT12872&restype=1&message=添加一条哦啊讨论啊&resId=216928&method=Send

                    YZResourceType resType = (YZResourceType)Enum.Parse(typeof(YZResourceType), context.Request.Params["resType"], true);
                    string         resId   = context.Request.Params["resId"];
                    string         msg     = context.Request.Params["message"];

                    if (!string.IsNullOrEmpty(msg.Trim()))
                    {
                        using (IDbConnection cn = dbProvider.OpenConnection())
                        {
                            YZMessage message = new YZMessage(loginUid, DateTime.Now, resType, resId, msg);
                            message.Insert(cn);

                            YZCommunicationManager.UpdateReaded(cn, loginUid, resType, resId, message.id);

                            JsonItem result = new JsonItem();
                            rv.Attributes.Add("message", result);
                            message.Serialize(result);
                        }
                    }
                }
                else if (method == "GetTaskCommunicationList")
                {
                    GridPageInfo gridPageInfo = new GridPageInfo(context);

                    SecurityToken token = null;
                    using (BPMConnection bpmcn = new BPMConnection())
                    {
                        bpmcn.WebOpen();
                        token = bpmcn.Token;
                    }

                    using (IDbConnection cn = dbProvider.OpenConnection())
                    {
                        //http://oauth.skyworthdigital.com/WebService/Iservice/Communication.ashx?UserAccount=SDT12872&method=GetTaskCommunicationList&SearchType=QuickSearch&Keyword=216928
                        //http://oauth.skyworthdigital.com/WebService/Iservice/Communication.ashx?UserAccount=SDT12872&method=GetTaskCommunicationList&SearchType=QuickSearch&Keyword=REQ2014090001

                        using (BPMConnection bpmcn = new BPMConnection())
                        {
                            bpmcn.WebOpen();

                            IDbCommand cmd = dbProvider.GetTaskCommunicationListCommand(cn, loginUid, token.SIDs, dbProvider.FilterStringCommunicationListTaskTableFilter, dbProvider.FilterStringCommunicationMessageTableFilter, gridPageInfo.Start, gridPageInfo.Limit);
                            cmd.Connection = cn;

                            JsonItemCollection children = new JsonItemCollection();
                            rv.Attributes.Add("children", children);

                            using (YZReader reader = new YZReader(cmd.ExecuteReader()))
                            {
                                while (reader.Read())
                                {
                                    JsonItem item = new JsonItem();
                                    children.Add(item);

                                    string ownerAccount     = reader.ReadString("OwnerAccount");
                                    User   owner            = User.TryGetUser(bpmcn, ownerAccount);
                                    string ownerDisplayName = owner != null ? owner.DisplayName : ownerAccount;

                                    string lastMsgUid  = reader.ReadString("uid");
                                    User   lastMsgUser = User.TryGetUser(bpmcn, lastMsgUid);
                                    string lastMessageUserShortName = lastMsgUser != null ? lastMsgUser.ShortName : lastMsgUid;

                                    TaskState state  = (TaskState)reader.ReadEnum("State", typeof(TaskState), TaskState.Unknow);
                                    int       taskid = reader.ReadInt32("TaskID");

                                    item.Attributes["tid"]       = taskid;
                                    item.Attributes["sn"]        = reader.ReadString("SerialNum");
                                    item.Attributes["pn"]        = reader.ReadString("ProcessName");
                                    item.Attributes["user"]      = YZStringHelper.GetUserShortName(ownerAccount, ownerDisplayName);
                                    item.Attributes["state"]     = state.ToString();
                                    item.Attributes["stateText"] = YZStringHelper.GetTaskStateDisplayString(bpmcn, state, taskid);
                                    item.Attributes["date"]      = YZStringHelper.DateToStringL(reader.ReadDateTime("CreateAt"));

                                    string desc = Convert.ToString(reader.ReadString("Description"));



                                    item.Attributes["desc"] = String.IsNullOrEmpty(desc) ? "无内容摘要" : desc.CutStrHTML(isHTML: true);

                                    item.Attributes["count"]                    = reader.ReadInt32("count");
                                    item.Attributes["total"]                    = reader.ReadInt32("total");
                                    item.Attributes["Id"]                       = reader.ReadInt32("Id");
                                    item.Attributes["lastMessageId"]            = reader.ReadInt32("lastMsgId");
                                    item.Attributes["lastMessageUid"]           = lastMsgUid;
                                    item.Attributes["lastMessageUserShortName"] = lastMessageUserShortName;
                                    item.Attributes["lastMessageDate"]          = YZStringHelper.DateToStringL(reader.ReadDateTime("date"));
                                    item.Attributes["lastMessage"]              = reader.ReadString("message");
                                }
                            }
                        }

                        rv.Attributes["newMessageCount"] = dbProvider.GetTaskCommunicationNewMessageCount(cn, loginUid, token.SIDs);
                    }
                }
                else if (method == "GetBadge")
                {
                    YZResourceType resType = (YZResourceType)Enum.Parse(typeof(YZResourceType), context.Request.Params["resType"], true);
                    string         resId   = context.Request.Params["resId"];

                    using (IDbConnection cn = dbProvider.OpenConnection())
                    {
                        rv.Attributes["total"]           = YZCommunicationManager.GetMessageCount(cn, resType, resId);
                        rv.Attributes["newMessageCount"] = YZCommunicationManager.GetNewMessageCount(cn, loginUid, resType, resId);
                    }
                }
                else if (method == "UpdateReaded")
                {
                    YZResourceType resType   = (YZResourceType)Enum.Parse(typeof(YZResourceType), context.Request.Params["resType"], true);
                    string         resId     = context.Request.Params["resId"];
                    string         strLastId = context.Request.Params["lastid"];
                    if (String.IsNullOrEmpty(strLastId))
                    {
                        strLastId = "-1";
                    }
                    int lastId = Convert.ToInt32(strLastId);

                    using (IDbConnection cn = dbProvider.OpenConnection())
                    {
                        YZCommunicationManager.UpdateReaded(cn, loginUid, resType, resId, lastId);
                    }
                }
                else
                {
                    //http://bpm.sdt.com/YZSoft/Forms/XForm/%E5%B7%A5%E4%BD%9C%E6%8A%A5%E5%91%8A/%E5%B7%A5%E4%BD%9C%E6%8A%A5%E5%91%8A.aspx?tid=216928
                    //http://oauth.skyworthdigital.com/WebService/Iservice/Communication.ashx?UserAccount=SDT12872&restype=1&lastid=306&resId=216928

                    YZResourceType resType   = (YZResourceType)Enum.Parse(typeof(YZResourceType), context.Request.Params["resType"], true);
                    string         resId     = context.Request.Params["resId"];
                    string         strLastId = context.Request.Params["lastid"];
                    if (String.IsNullOrEmpty(strLastId))
                    {
                        strLastId = "-1";
                    }
                    int lastId = Convert.ToInt32(strLastId);

                    //获得数据
                    JsonItemCollection children = new JsonItemCollection();
                    rv.Attributes.Add("children", children);

                    using (BPMConnection bpmcn = new BPMConnection())
                    {
                        bpmcn.WebOpen();

                        using (IDbConnection cn = dbProvider.OpenConnection())
                        {
                            YZMessageCollection messages = YZCommunicationManager.GetNewMessages(cn, resType, resId, lastId);
                            messages.Serialize(bpmcn, children);
                        }
                    }
                }


                //输出数据
                context.Response.AppendHeader("Access-Control-Allow-Origin", "*");      // 响应类型
                context.Response.AppendHeader("Access-Control-Allow-Methods", "POST");  // 响应头设置
                context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

                context.Response.Charset         = "gb2312"; //设置字符集类型
                context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                context.Response.ContentType     = "application/json;charset=gb2312";

                //输出数据
                rv.Attributes.Add("success", true);
                context.Response.Write(rv.ToString());
            }
            catch (Exception e)
            {
                JsonItem rv = new JsonItem();

                context.Response.AppendHeader("Access-Control-Allow-Origin", "*");      // 响应类型
                context.Response.AppendHeader("Access-Control-Allow-Methods", "POST");  // 响应头设置
                context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

                context.Response.Charset         = "gb2312"; //设置字符集类型
                context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                context.Response.ContentType     = "application/json;charset=gb2312";

                rv.Attributes.Add("success", false);
                rv.Attributes.Add("errorMessage", e.Message);
                context.Response.Write(rv.ToString());
            }
        }
Exemplo n.º 21
0
    protected static void DefaultRender(HSSFCell cell, string varName, DataSet dataset, object value, string emptyText)
    {
        //SQL Server数据库中monery4位小数点处理
        if (value is decimal)
        {
            value = (decimal)Decimal.ToDouble((decimal)value);
        }

        //部分替换的情况
        if (!String.IsNullOrEmpty(varName))
        {
            if (cell.CellType == CellType.STRING)
            {
                string orgText = cell.StringCellValue;
                string newText = orgText.Replace(varName, Convert.ToString(value));
                cell.SetCellValue(newText);
            }

            return;
        }

        if (String.IsNullOrEmpty(Convert.ToString(value)))
        {
            cell.SetCellValue(emptyText);
            return;
        }

        //如果单元格定义了格式,则应用单元格上定义的格式
        //如果单元格未定义格式,则根据值设置格式
        switch (cell.CellType)
        {
        case CellType.BOOLEAN:
        {
            cell.SetCellValue(Convert.ToBoolean(value));
            break;
        }

        case CellType.NUMERIC:
        {
            if (value is DateTime)
            {
                SetCellValueDate(cell, Convert.ToDateTime(value), emptyText);
            }
            else if (value is String)
            {
                string strValue = (string)value;

                double doubleValue;
                if (Double.TryParse(strValue, out doubleValue))
                {
                    cell.SetCellValue(doubleValue);
                    break;
                }

                DateTime dateValue = DateTime.MinValue;
                if (DateTime.TryParse(strValue, out dateValue))
                {
                    SetCellValueDate(cell, dateValue, emptyText);
                    break;
                }

                cell.SetCellValue(strValue);
            }
            else
            {
                cell.SetCellValue(Convert.ToDouble(value));
            }
            break;
        }

        case CellType.BLANK:     //未定义格式 - 根据值设置格式
        {
            TypeCode typeCode = Type.GetTypeCode(value.GetType());
            switch (typeCode)
            {
            case TypeCode.Boolean:
                cell.SetCellValue(Convert.ToBoolean(value));
                break;

            case TypeCode.DateTime:
                SetCellValueDate(cell, Convert.ToDateTime(value), emptyText);
                break;

            case TypeCode.Decimal:
            case TypeCode.Double:
            case TypeCode.Int16:
            case TypeCode.Int32:
            case TypeCode.Int64:
            case TypeCode.Single:
            case TypeCode.UInt16:
            case TypeCode.UInt32:
            case TypeCode.UInt64:
            case TypeCode.SByte:
            case TypeCode.Byte:
                cell.SetCellValue(Convert.ToDouble(value));
                break;

            default:
                cell.SetCellValue(Convert.ToString(value));
                break;
            }
            break;
        }

        case CellType.STRING:
        {
            if (value is DateTime)
            {
                DateTime date = (DateTime)value;
                value = date == DateTime.MinValue ? "" : YZStringHelper.DateToStringL(date);
            }

            cell.SetCellValue(Convert.ToString(value));
            break;
        }
        }
    }