Exemple #1
0
        public virtual object GetOrgTree(HttpContext context)
        {
            YZRequest      request        = new YZRequest(context);
            string         path           = request.GetString("node", null);
            string         srcoupath      = request.GetString("srcoupath", null);
            GetRootOUsType getRootOUsType = request.GetEnum <GetRootOUsType>("getRootOUsType", GetRootOUsType.All);

            if (YZStringHelper.EquName(path, "root"))
            {
                path = null;
            }

            JObject rv = new JObject();

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

                JArray children = new JArray();
                rv[YZJsonProperty.children] = children;

                if (String.IsNullOrEmpty(path))
                {
                    SecurityToken token         = cn.Token;
                    JObject       dirParentItem = null;

                    this.Expand(cn, children, path, token, ref dirParentItem, getRootOUsType, srcoupath);

                    if (dirParentItem != null)
                    {
                        dirParentItem["dirou"] = true;

                        //没必要列出所在部门的子部门
                        //dirParentItem["expanded"] = false;
                        //dirParentItem.ChildItems.Clear();
                    }
                }
                else
                {
                    OUCollection ous = OU.GetChildren(cn, path);

                    foreach (OU ou in ous)
                    {
                        JObject item = new JObject();
                        item["leaf"]       = false;
                        item["text"]       = ou.Name;
                        item["iconCls"]    = "folder";
                        item["id"]         = ou.FullName;
                        item["enpandable"] = true;
                        children.Add(item);

                        item["data"] = this.GetNodeData(ou);
                    }
                }
            }

            //输出数据
            return(rv);
        }
Exemple #2
0
        public virtual object GetFolders(HttpContext context)
        {
            YZRequest request    = new YZRequest(context);
            string    serverName = request.GetString("serverName");
            string    path       = request.GetString("node", null);

            if (YZStringHelper.EquName(path, "root"))
            {
                path = null;
            }

            LocalServer localServer = new LocalServer();

            localServer.Name = "localhost";

            JObject rv = new JObject();

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

                JArray children = new JArray();
                rv[YZJsonProperty.children] = children;

                if (String.IsNullOrEmpty(path))
                {
                    FSSDriveInfoCollection drivers = FileStoreManager.GetDrivers(cn, serverName);
                    foreach (FSSDriveInfo driveInfo in drivers)
                    {
                        JObject item = new JObject();
                        children.Add(item);
                        item["iconCls"]    = "bdisk";
                        item["text"]       = driveInfo.VolumeLabel + " (" + driveInfo.Name.Substring(0, 2) + ")";
                        item["path"]       = driveInfo.Path;
                        item["leaf"]       = false;
                        item["expanded"]   = false;
                        item["enpandable"] = true;
                    }
                }

                FSSFolderInfoCollection folders = FileStoreManager.GetFolders(cn, serverName, path);
                foreach (FSSFolderInfo folderInfo in folders)
                {
                    JObject item = new JObject();
                    children.Add(item);
                    item["iconCls"]    = "folder";
                    item["text"]       = folderInfo.Name;
                    item["path"]       = folderInfo.Path;
                    item["leaf"]       = false;
                    item["expanded"]   = false;
                    item["enpandable"] = true;
                }
            }

            //输出数据
            return(rv);
        }
Exemple #3
0
        protected virtual string GetFilterStringHistoryTaskStep(YZRequest request, IYZDbProvider provider)
        {
            string filter = null;
            string status = request.GetString("status", null);

            if (YZStringHelper.EquName(status, TaskState.Running.ToString()))
            {
                string recipientUserAccount = request.GetString("RecipientUserAccount", null);
                if (!String.IsNullOrEmpty(recipientUserAccount))
                {
                    filter = provider.CombinCond(filter, String.Format("(FinishAt IS NULL AND (OwnerAccount=N'{0}' OR AgentAccount=N'{0}'))", provider.EncodeText(recipientUserAccount)));
                }
            }

            return(filter);
        }
Exemple #4
0
        protected virtual string GetTimeoutMonitorWorklistFilterString(YZRequest request, IYZDbProvider provider)
        {
            string filter      = null;
            string searchType  = request.GetString("SearchType", null);
            string searchBy    = request.GetString("SearchBy", null);
            string processName = request.GetString("ProcessName", null);

            if (!String.IsNullOrEmpty(processName))
            {
                filter = String.Format("ProcessName=N'{0}'", provider.EncodeText(processName));
            }

            if (!YZStringHelper.EquName(searchType, "AdvancedSearch"))
            {
                filter = provider.CombinCond(filter, "Progress >= 1");
            }
            else
            {
                if (YZStringHelper.EquName(searchBy, "Progress"))
                {
                    decimal minProgress = request.GetDecimal("minProgress");
                    decimal maxProgress = request.GetDecimal("maxProgress", -1);

                    filter = provider.CombinCond(filter, String.Format("Progress >= {0}", minProgress));

                    if (maxProgress != -1)
                    {
                        filter = provider.CombinCond(filter, String.Format("Progress < {0}", maxProgress));
                    }
                }
                else
                {
                    DateTime deadline = request.GetDateTime("Deadline");
                    filter = provider.CombinCond(filter, String.Format("TimeoutDeadline IS NOT NULL AND Progress < 10000 AND TimeoutDeadline <= {0}", provider.DateToQueryString(deadline)));
                }
            }

            return(filter);
        }
Exemple #5
0
        protected virtual string GetFilterString(YZRequest request, IYZDbProvider provider)
        {
            string filter = null;

            string searchType = request.GetString("SearchType", null);
            string keyword    = request.GetString("Kwd", null);

            string clienIPLike   = null;
            string accountLike   = null;
            string actionLike    = null;
            string actParam1Like = null;
            string actParam2Like = null;
            string errLike       = null;

            if (!String.IsNullOrEmpty(keyword))
            {
                clienIPLike   = String.Format("ClientIP LIKE(N'%{0}%')", provider.EncodeText(keyword));
                accountLike   = String.Format("UserAccount LIKE(N'%{0}%')", provider.EncodeText(keyword));
                actionLike    = String.Format("Action LIKE(N'%{0}%')", provider.EncodeText(keyword));
                actParam1Like = String.Format("ActParam1 LIKE(N'%{0}%')", provider.EncodeText(keyword));
                actParam2Like = String.Format("ActParam2 LIKE(N'%{0}%')", provider.EncodeText(keyword));
                errLike       = String.Format("Error LIKE(N'%{0}%')", provider.EncodeText(keyword));
            }

            if (YZStringHelper.EquName(searchType, "AdvancedSearch"))
            {
                string account  = request.GetString("Account", null);
                string action   = request.GetString("Action", null);
                string result   = request.GetString("Result", null);
                string clientIP = request.GetString("ClientIP", null);

                string keywordFilter = null;

                if (!String.IsNullOrEmpty(account))
                {
                    filter = provider.CombinCond(filter, String.Format("UserAccount=N'{0}'", provider.EncodeText(account)));
                }
                else
                {
                    keywordFilter = provider.CombinCondOR(keywordFilter, accountLike);
                }

                if (action != "all")
                {
                    filter = provider.CombinCond(filter, String.Format("Action=N'{0}'", provider.EncodeText(action)));
                }
                else
                {
                    keywordFilter = provider.CombinCondOR(keywordFilter, actionLike);
                }

                if (result == YZJsonProperty.success)
                {
                    filter = provider.CombinCond(filter, "Succeed=1");
                }
                if (result == "Failed")
                {
                    filter = provider.CombinCond(filter, "Succeed=0");
                }

                if (!String.IsNullOrEmpty(clientIP))
                {
                    filter = provider.CombinCond(filter, String.Format("ClientIP=N'{0}'", provider.EncodeText(clientIP)));
                }
                else
                {
                    keywordFilter = provider.CombinCondOR(keywordFilter, clienIPLike);
                }

                if (!String.IsNullOrEmpty(keyword))
                {
                    keywordFilter = provider.CombinCondOR(keywordFilter, actParam1Like);
                    keywordFilter = provider.CombinCondOR(keywordFilter, actParam2Like);
                    keywordFilter = provider.CombinCondOR(keywordFilter, errLike);
                }

                filter = provider.CombinCond(filter, keywordFilter);
            }

            return(filter);
        }
Exemple #6
0
        public virtual JObject GetPostInfo(HttpContext context)
        {
            YZRequest request       = new YZRequest(context);
            string    processName   = request.GetString("pn", null);
            int       restartTaskID = request.GetInt32("restartTaskID", -1);
            string    owner         = request.GetString("owner", null);
            string    permisions    = request.GetString("Permisions", null);
            string    did           = request.GetString("did", null);

            Version          processVersion = null;
            PostInfo         postInfo;
            JObject          perm;
            BPMDraft         draft        = null;
            JObject          jDraftHeader = null;
            bool             delagation;
            string           selectPosition;
            MemberCollection positions;
            JObject          rv = new JObject();
            PostSubModel     subModel;

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

                if (!String.IsNullOrEmpty(did))
                {
                    draft = new BPMDraft();
                    draft.Open(cn, new Guid(did));
                    processName = draft.ProcessName;

                    if (!String.IsNullOrEmpty(draft.Header))
                    {
                        jDraftHeader = JObject.Parse(draft.Header);
                    }
                }

                if (draft != null)
                {
                    subModel = (PostSubModel)Enum.Parse(typeof(PostSubModel), draft.Type.ToString());
                }
                else
                {
                    subModel = PostSubModel.Post;
                }

                if (restartTaskID == -1)
                {
                    processVersion = cn.GetGlobalObjectLastVersion(StoreZoneType.Process, processName);
                }

                postInfo = BPMProcess.GetPostInfo(cn, processName, processVersion, owner, restartTaskID);
                perm     = this.CheckPermision(postInfo, permisions);

                //获得delagation/selectPosition
                if (draft != null)
                {
                    selectPosition = PositionManager.MemberFullNameFromID(cn, draft.OwnerPositionID);
                    delagation     = !YZStringHelper.EquName(draft.OwnerAccount, cn.UID);
                }
                else
                {
                    if (postInfo.IsPostByAgent)
                    {
                        delagation     = true;
                        selectPosition = owner;
                    }
                    else
                    {
                        delagation     = false;
                        selectPosition = owner;
                    }
                }

                //获得positions
                if (!delagation)
                {
                    positions = OrgSvr.GetUserPositions(cn, cn.UID);
                    if (String.IsNullOrEmpty(selectPosition) && positions.Count != 0)
                    {
                        selectPosition = positions[0].FullName;
                    }
                }
                else
                {
                    Member mb = new Member();
                    mb.Open(cn, selectPosition);
                    positions      = OrgSvr.GetUserPositions(cn, mb.UserAccount);
                    selectPosition = mb.FullName;
                }

                if (String.IsNullOrEmpty(postInfo.FormFile))
                {
                    throw new Exception(Resources.YZStrings.Aspx_Post_MissForm);
                }

                //返回
                rv[YZJsonProperty.success] = true;
                rv["subModel"]             = subModel.ToString();

                //基本信息
                rv["pn"]             = postInfo.ProcessName;
                rv["version"]        = postInfo.ProcessVersion.ToString(2);
                rv["restartTaskID"]  = restartTaskID;
                rv["url"]            = YZUtility.GetFormRedirectUrl(postInfo.FormFile).ToString();
                rv["perm"]           = perm;
                rv["PersistParams"]  = postInfo.PersistParams;
                rv["NodePermisions"] = this.Serialize(postInfo.NodePermision);

                rv["Comments"]    = draft != null ? draft.Comments : null;
                rv["DraftHeader"] = jDraftHeader;

                //处理按钮
                JArray links = new JArray();
                rv["links"] = links;
                foreach (Link link in postInfo.Links)
                {
                    links.Add(this.Serialize(link, "normal"));
                }

                //提交职位
                rv["delagation"]     = delagation;
                rv["selectPosition"] = selectPosition;
                JArray jPoss = new JArray();
                rv["positions"] = jPoss;
                foreach (Member position in positions)
                {
                    JObject jPos = new JObject();
                    jPoss.Add(jPos);

                    string name = position.GetParentOU(cn).Name + "\\" + position.UserAccount;

                    if (position.IsLeader)
                    {
                        name += "(" + position.LeaderTitle + ")";
                    }

                    jPos["name"]  = name;
                    jPos["value"] = position.FullName;
                }

                //自由流
                rv["ParticipantDeclares"] = JArray.FromObject(postInfo.ParticipantDeclares);
            }
            return(rv);
        }
Exemple #7
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                YZAuthHelper.OAuth();

                //YZAuthHelper.AshxAuthCheck();

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

                if (YZStringHelper.EquName(method, "GET"))
                {
                    string uid = YZAuthHelper.LoginUserAccount;
                    using (BPMConnection cn = new BPMConnection())
                    {
                        JsonItem data = new JsonItem();
                        JosonRv.Attributes.Add("data", data);

                        cn.WebOpen();

                        UserAccount currentUser = cn.getCurrentUser(uid);


                        User user = User.FromAccount(cn, uid);

                        #region 用户信息
                        data.Attributes["Account"]     = user.Account;
                        data.Attributes["HRID"]        = user.HRID;
                        data.Attributes["DisplayName"] = user.ShortName;
                        data.Attributes["Mobile"]      = user.Mobile;
                        data.Attributes["OfficePhone"] = user.OfficePhone;
                        data.Attributes["HomePhone"]   = user.HomePhone;
                        data.Attributes["EMail"]       = user.EMail;
                        data.Attributes["Office"]      = user.Office;
                        data.Attributes["Birthday"]    = YZStringHelper.DateToString(user.Birthday);
                        data.Attributes["DateHired"]   = YZStringHelper.DateToString(user.DateHired);
                        data.Attributes["Desc"]        = user.Description;
                        #endregion

                        #region 获得OU
                        //获得OU
                        String OULevel = String.Empty;
                        String OUName  = String.Empty;
                        String Dept    = String.Empty;
                        BPMObjectNameCollection depts   = new BPMObjectNameCollection();
                        MemberCollection        members = OrgSvr.GetUserPositions(cn, uid);
                        foreach (Member member in members)
                        {
                            OU ou = member.GetParentOU(cn);
                            OULevel = ou.OULevel;
                            Dept    = ou.Name;

                            String FullName    = member.GetParentOU(cn).FullName;
                            String mFullName   = member.FullName;
                            String mDepartment = member.Department;


                            if (!ou.IsRootOU)
                            {
                                OUName = mFullName.Split(new char[2] {
                                    '/', '/'
                                })[2];
                                depts.Add(OUName);
                            }
                            else
                            {
                                OUName = ou.Name;
                            }

                            if (String.IsNullOrEmpty(member.LeaderTitle))
                            {
                                depts.Add(ou.Name);
                            }
                            else
                            {
                                depts.Add(String.Format("{0}({1})", ou.Name, member.LeaderTitle));
                            }
                        }

                        data.Attributes["Dept"] = String.Join(" > ", depts.ToArray());
                        #endregion


                        UserCommonInfo userCommonInfo = UserCommonInfo.FromAccount(cn, uid);

                        data.Attributes["AppSN"]      = Net.Common.JosonRandom.GetRandomByDateTime(1, 999).Replace("/", "");
                        data.Attributes["AppCompany"] = OUName.GetShortName();
                        data.Attributes["AppDept"]    = Dept;
                        data.Attributes["AppDate"]    = DateTime.Now;
                        data.Attributes["AppHRName"]  = user.ShortName;
                        data.Attributes["AppHRID"]    = YZAuthHelper.LoginUserAccount;
                        data.Attributes["isSkyWorth"] = currentUser.AppFristDept != "制造中心" ? 0 : 1;
                        data.Attributes["AppComDept"] = currentUser.AppCompany.ToConnects("\\") + currentUser.AppDept;



                        JosonRv.Attributes.Add("success", true);
                        JosonRv.Attributes.Add("successMessage", "ok");
                        context.Response.Write(JosonRv.ToString());
                    }
                }
                else if (YZStringHelper.EquName(method, "Submit"))
                {
                    //遍历File表单元素
                    //HttpFileCollection files = HttpContext.Current.Request.Files;
                    //try
                    //{
                    //    for (int iFile = 0; iFile < files.Count; iFile++)
                    //    {
                    //        ///检查文件扩展名字
                    //        HttpPostedFile postedFile = files[iFile];
                    //        string fileName, fileExtension;
                    //        fileName = System.IO.Path.GetFileName(postedFile.FileName);
                    //        if (fileName != "")
                    //        {
                    //            ///注意:可能要修改你的文件夹的匿名写入权限。
                    //            postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("YZSoft/attachment/") + fileName);
                    //        }
                    //    }

                    //    HttpContext.Current.Response.Write("{success:true,msg:'File was successfully uploaded.'}");
                    //}
                    //catch (System.Exception Ex)
                    //{
                    //    HttpContext.Current.Response.Write("{success:true,msg:'File was successfully uploaded.'}");
                    //}



                    #region 接收数据
                    string uid = YZAuthHelper.LoginUserAccount;

                    string EmpID       = Convert.ToString(context.Request.Params["AppHRID"]);
                    string EmpName     = Convert.ToString(context.Request.Params["AppHRName"]);
                    string LeaveID     = Convert.ToString(context.Request.Params["LeaveID"]);
                    string LeaveName   = Convert.ToString(context.Request.Params["LeaveName"]);
                    string LeaveTypeID = Convert.ToString(context.Request.Params["LeaveTypeID"]);


                    String   AppSN      = Convert.ToString(context.Request.Params["AppSN"]);
                    String   AppCompany = Convert.ToString(context.Request.Params["AppCompany"]);
                    String   AppDept    = Convert.ToString(context.Request.Params["AppDept"]);
                    DateTime AppDate    = Convert.ToDateTime(context.Request.Params["AppDate"]);
                    String   AppHRName  = Convert.ToString(context.Request.Params["AppHRName"]);
                    String   AppHRID    = Convert.ToString(context.Request.Params["AppHRID"]);

                    String Address = Convert.ToString(context.Request.Params["Address"]);

                    DateTime FromDate = YZStringHelper.StringToDate(context.Request.Params["startTime"]);
                    DateTime ToDate   = YZStringHelper.StringToDate(context.Request.Params["endTime"]);

                    String allHours = Convert.ToString(context.Request.Params["allHours"]);
                    int    DayInt   = Convert.ToInt32(allHours.Split('天')[0]);
                    int    HourInt  = Convert.ToInt32(allHours.Split('天')[1].Split('小')[0]);


                    String reasonWhyNote = Convert.ToString(context.Request.Params["reasonWhy"]);
                    String suggestionMsg = Convert.ToString(context.Request.Params["suggestionMsg"]);
                    String strAttachment = Convert.ToString(context.Request.Params["strAttachment"]);

                    int isSkyWorth = Convert.ToInt32(context.Request.Params["isSkyWorth"]);



                    #region  iPHone 早期版本 客户端Bug修改

                    String strFromClient = submitFrom.UserAgent(context);

                    //if (suggestionMsg.IndexOf("iphone") > -1 || suggestionMsg.IndexOf("iPhone") > -1)
                    //{

                    //    if (LeaveTypeID == "20")
                    //    {
                    //        LeaveTypeID = "30";

                    //    }
                    //    else
                    //    {
                    //        LeaveTypeID = LeaveTypeID == "30" ? "20" : LeaveTypeID;
                    //    }
                    //}

                    #endregion


                    #endregion

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

                        //  Net.Common.GetRequestForm.Post<T>

                        //   http://extjs.org.cn/node/712


                        #region 提交数据
                        MemoryStream xmlStream = GeneratePostXML(Guid.NewGuid(), cn
                                                                 , AppSN
                                                                 , AppHRID
                                                                 , AppHRName
                                                                 , AppDate
                                                                 , AppDept
                                                                 , AppCompany

                                                                 , EmpID
                                                                 , EmpName
                                                                 , LeaveID
                                                                 , LeaveName
                                                                 , LeaveTypeID
                                                                 , FromDate
                                                                 , ToDate
                                                                 , DayInt
                                                                 , HourInt
                                                                 , reasonWhyNote + suggestionMsg + "\n\r" + strFromClient
                                                                 , strAttachment
                                                                 , isSkyWorth

                                                                 );
                        #endregion

                        PostResult result      = BPMProcess.Post(cn, xmlStream);
                        String     DisplayName = result.Recipients[0].Owner.DisplayName;

                        //JsonItem JosonRv = new JsonItem();
                        JosonRv.Attributes.Add("success", true);
                        JosonRv.Attributes.Add("successMessage", "\n\r <BR> 流程【" + result.SN + "】\n\r <BR> 成功提交给 " + DisplayName);
                        context.Response.Write(JosonRv.ToString());
                    }
                }
                else
                {
                    String strMsg = String.Format(JosonStrings.Aspx_UnknowCommand, method);

                    //JsonItem JosonRv = new JsonItem();
                    JosonRv.Attributes.Add("success", false);
                    JosonRv.Attributes.Add("errorMessage", strMsg);

                    context.Response.Write(JosonRv.ToString());

                    throw new Exception(strMsg);
                }

                //System.Threading.Thread.Sleep(500);
            }
            catch (Exception e)
            {
                JsonItem JosonRv = new JsonItem();
                JosonRv.Attributes.Add("success", false);
                JosonRv.Attributes.Add("errorMessage", e.Message);
                context.Response.Write(JosonRv.ToString());
            }
        }
Exemple #8
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());
            }
        }
Exemple #9
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                YZAuthHelper.OAuth();

                //YZAuthHelper.AshxAuthCheck();

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

                if (YZStringHelper.EquName(method, "GET"))
                {
                    string uid = YZAuthHelper.LoginUserAccount;
                    using (BPMConnection cn = new BPMConnection())
                    {
                        JsonItem data = new JsonItem();
                        JosonRv.Attributes.Add("data", data);

                        cn.WebOpen();

                        UserAccount currentUser = cn.getCurrentUser(uid);

                        //User user = User.FromAccount(cn, uid);
                        //UserCommonInfo userCommonInfo = UserCommonInfo.FromAccount(cn, uid);

                        data.Attributes["AppSN"]      = currentUser.AppSN;
                        data.Attributes["AppCompany"] = currentUser.AppCompany;
                        data.Attributes["AppDept"]    = currentUser.AppDept;
                        data.Attributes["AppDate"]    = currentUser.SubmitDateTime;
                        data.Attributes["AppHRName"]  = currentUser.ShortName;
                        data.Attributes["AppHRID"]    = currentUser.AppHRID;
                        data.Attributes["isSkyWorth"] = currentUser.AppFristDept != "制造中心" ? 0 : 1;

                        data.Attributes["AppComDept"] = currentUser.AppCompany.ToConnects("\\") + currentUser.AppDept;


                        JosonRv.Attributes.Add("success", true);
                        JosonRv.Attributes.Add("successMessage", "ok");
                        context.Response.Write(JosonRv.ToString());
                    }
                }
                else if (YZStringHelper.EquName(method, "Submit"))
                {
                    #region 接收数据


                    String   AppSN      = Convert.ToString(context.Request.Params["AppSN"]);
                    String   AppCompany = Convert.ToString(context.Request.Params["AppCompany"]);
                    String   AppDept    = Convert.ToString(context.Request.Params["AppDept"]);
                    DateTime AppDate    = Convert.ToDateTime(context.Request.Params["AppDate"]);
                    String   AppHRName  = Convert.ToString(context.Request.Params["AppHRName"]);
                    String   AppHRID    = Convert.ToString(context.Request.Params["AppHRID"]);


                    string EmpID   = Convert.ToString(context.Request.Params["AppHRID"]);
                    string EmpName = Convert.ToString(context.Request.Params["AppHRName"]);
                    String Address = Convert.ToString(context.Request.Params["Address"]);

                    DateTime FromDate = YZStringHelper.StringToDate(context.Request.Params["startTime"]);
                    DateTime ToDate   = YZStringHelper.StringToDate(context.Request.Params["endTime"]);

                    String allHours = Convert.ToString(context.Request.Params["allHours"]);
                    int    DayInt   = Convert.ToInt32(allHours.Split('天')[0]);
                    int    HourInt  = Convert.ToInt32(allHours.Split('天')[1].Split('小')[0]);


                    String strVehicle   = Convert.ToString(context.Request.Params["Vehicle"]);
                    String OtherVehicle = Convert.ToString(context.Request.Params["OtherVehicle"]);

                    String reasonWhyNote = Convert.ToString(context.Request.Params["reasonWhy"]);
                    String suggestionMsg = Convert.ToString(context.Request.Params["suggestionMsg"]);
                    String strAttachment = Convert.ToString(context.Request.Params["strAttachment"]);

                    int isSkyWorth = Convert.ToInt32(context.Request.Params["isSkyWorth"]);

                    #endregion

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

                        //  Net.Common.GetRequestForm.Post<T>

                        //   http://extjs.org.cn/node/712


                        #region 提交数据
                        MemoryStream xmlStream = GeneratePostXML(Guid.NewGuid(), cn
                                                                 , AppSN
                                                                 , AppHRID
                                                                 , AppHRName
                                                                 , AppDate
                                                                 , AppDept
                                                                 , AppCompany

                                                                 , EmpID
                                                                 , EmpName

                                                                 , Address
                                                                 , FromDate
                                                                 , ToDate
                                                                 , DayInt
                                                                 , HourInt
                                                                 , reasonWhyNote + suggestionMsg
                                                                 , strAttachment
                                                                 , isSkyWorth

                                                                 );
                        #endregion

                        PostResult result      = BPMProcess.Post(cn, xmlStream);
                        String     DisplayName = result.Recipients[0].Owner.DisplayName;

                        //JsonItem JosonRv = new JsonItem();
                        JosonRv.Attributes.Add("success", true);
                        JosonRv.Attributes.Add("successMessage", "\n\r <BR> 流程【" + result.SN + "】\n\r <BR> 成功提交给 " + DisplayName);
                        context.Response.Write(JosonRv.ToString());
                    }
                }
                else
                {
                    String strMsg = String.Format(JosonStrings.Aspx_UnknowCommand, method);

                    //JsonItem JosonRv = new JsonItem();
                    JosonRv.Attributes.Add("success", false);
                    JosonRv.Attributes.Add("errorMessage", strMsg);

                    context.Response.Write(JosonRv.ToString());

                    throw new Exception(strMsg);
                }

                //System.Threading.Thread.Sleep(500);
            }
            catch (Exception e)
            {
                JsonItem JosonRv = new JsonItem();
                JosonRv.Attributes.Add("success", false);
                JosonRv.Attributes.Add("errorMessage", e.Message);
                context.Response.Write(JosonRv.ToString());
            }
        }
Exemple #10
0
    public static string GetSelActionDisplayString(BPMProcStep step)
    {
        if (!step.Finished)
        {
            return(Resources.YZStrings.All_Running);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Abort))
        {
            return(Resources.YZStrings.Aspx_SysAct_Abort);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.RecedeBack))
        {
            return(Resources.YZStrings.Aspx_SysAct_RecedeBack);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.AssignOwner))
        {
            return(Resources.YZStrings.Aspx_SysAct_AssignOwner);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Continue))
        {
            return(Resources.YZStrings.Aspx_SysAct_Continue);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Delete))
        {
            return(Resources.YZStrings.Aspx_SysAct_Delete);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Jump))
        {
            return(Resources.YZStrings.Aspx_SysAct_Jump + "(" + step.Memo + ")");
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.TimeoutJump))
        {
            return(Resources.YZStrings.Aspx_SysAct_TimeoutJump + "(" + step.Memo + ")");
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.PickBackRestart))
        {
            return("重新取回");// Resources.YZStrings.Aspx_SysAct_PickbackRestart;
        }
        if (YZStringHelper.EquName(step.SelAction, SystemAction.PickBack))
        {
            return("取回");// Resources.YZStrings.Aspx_SysAct_Pickback;
        }
        if (YZStringHelper.EquName(step.SelAction, SystemAction.RecedeRestart))
        {
            return(Resources.YZStrings.Aspx_SysAct_RecedeRestart);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Reject))
        {
            return(Resources.YZStrings.Aspx_SysAct_Reject);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Transfer))
        {
            return(Resources.YZStrings.Aspx_SysAct_Agent);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.DirectSend))
        {
            return(Resources.YZStrings.Aspx_SysAct_DirectSend);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.InviteIndicate))
        {
            return(Resources.YZStrings.Aspx_SysAct_InviteIndicate);
        }

        if (!step.AutoProcess)
        {
            return(step.SelAction);
        }
        else
        {
            return(step.SelAction + "(" + Resources.YZStrings.Aspx_Auto + ")");
        }
    }
Exemple #11
0
    public static DataSet LoadExcel(Stream stream, string fileName, int titleRowIndex, int dataRowIndex, bool ignoreCellException)
    {
        //打开文件
        IWorkbook         book      = null;
        IFormulaEvaluator evaluator = null;

        string ext = Path.GetExtension(fileName);

        if (YZStringHelper.EquName(ext, ".xlsx"))
        {
            book      = new XSSFWorkbook(stream);
            evaluator = new XSSFFormulaEvaluator(book);
        }

        if (book == null)
        {
            book      = new HSSFWorkbook(stream);
            evaluator = new HSSFFormulaEvaluator(book);
        }

        DataSet dataset = new DataSet();

        for (int i = 0; i < book.NumberOfSheets; i++)
        {
            ISheet sheet = (ISheet)book.GetSheetAt(i);

            DataTable table = new DataTable(sheet.SheetName);
            dataset.Tables.Add(table);

            if (sheet.LastRowNum != 0)
            {
                for (int r = 0; r <= sheet.LastRowNum; r++)
                {
                    IRow row = (IRow)sheet.GetRow(r);
                    if (row == null) //存在row为null的情况
                    {
                        break;       // continue;
                    }
                    DataRow dataRow       = null;
                    bool    containsValue = false;
                    for (int c = 0; c < row.LastCellNum; c++)
                    {
                        ICell  cell  = (ICell)row.GetCell(c); //存在cell为null的情况
                        object value = cell == null ? null : YZExcelHelper.GetCellValue(evaluator, cell, ignoreCellException);
                        if (!String.IsNullOrEmpty(Convert.ToString(value)))
                        {
                            containsValue = true;
                        }

                        string columnName = YZExcelHelper.ColumnIndexToName(c);
                        if (r == titleRowIndex)
                        {
                            DataColumn dataColumn = new DataColumn(columnName, typeof(object));
                            table.Columns.Add(dataColumn);
                            dataColumn.Caption = Convert.ToString(value);
                        }
                        else if (r >= dataRowIndex)
                        {
                            if (!table.Columns.Contains(columnName))
                            {
                                DataColumn dataColumn = new DataColumn(columnName, typeof(object));
                                table.Columns.Add(dataColumn);
                            }

                            if (dataRow == null)
                            {
                                dataRow = table.NewRow();
                            }

                            dataRow[columnName] = value;

                            if (c == row.LastCellNum - 1 && containsValue)
                            {
                                table.Rows.Add(dataRow);
                            }
                        }
                    }
                }
            }
        }

        return(dataset);
    }
Exemple #12
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                YZAuthHelper.OAuth();

                //YZAuthHelper.AshxAuthCheck();

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

                if (YZStringHelper.EquName(method, "GET"))
                {
                    string uid = YZAuthHelper.LoginUserAccount;
                    using (BPMConnection cn = new BPMConnection())
                    {
                        JsonItem data = new JsonItem();
                        rv.Attributes.Add("data", data);

                        cn.WebOpen();

                        User user = User.FromAccount(cn, uid);
                        UserInfoSelfMantSetting setting = new UserInfoSelfMantSetting();
                        setting.Load(cn);

                        data.Attributes["Account"]     = user.Account;
                        data.Attributes["HRID"]        = user.HRID;
                        data.Attributes["DisplayName"] = user.DisplayName;
                        data.Attributes["Mobile"]      = user.Mobile;
                        data.Attributes["OfficePhone"] = user.OfficePhone;
                        data.Attributes["HomePhone"]   = user.HomePhone;
                        data.Attributes["EMail"]       = user.EMail;
                        data.Attributes["Office"]      = user.Office;
                        data.Attributes["Birthday"]    = YZStringHelper.DateToString(user.Birthday);
                        data.Attributes["DateHired"]   = YZStringHelper.DateToString(user.DateHired);

                        data.Attributes["editableFields"] = "DisplayName,HRID,Mobile,OfficePhone,HomePhone,EMail,Office,Birthday,DateHired";
                        //data.Attributes["editableFields"] = "Mobile,OfficePhone,HomePhone,EMail,Office";

                        //获得所有主管
                        BPMObjectNameCollection depts       = new BPMObjectNameCollection();
                        BPMObjectNameCollection supervisors = new BPMObjectNameCollection();
                        MemberCollection        members     = OrgSvr.GetUserPositions(cn, uid);
                        foreach (Member member in members)
                        {
                            OU ou = member.GetParentOU(cn);
                            depts.Add(ou.Name);

                            SupervisorCollection spvs = Member.GetSupervisors(cn, member.FullName);
                            foreach (Supervisor spv in spvs)
                            {
                                if (!supervisors.Contains(spv.UserFriendlyName))
                                {
                                    supervisors.Add(spv.UserFriendlyName);
                                }
                            }
                        }

                        data.Attributes["Supervisor"] = String.Join(",", supervisors.ToArray());
                        data.Attributes["Dept"]       = String.Join(",", depts.ToArray());
                    }
                }
                else if (YZStringHelper.EquName(method, "UPDATE"))
                {
                    string   uid       = YZAuthHelper.LoginUserAccount;
                    string   fieldName = context.Request.Params["fieldName"];
                    string   strValue  = context.Request.Params["value"];
                    DateTime date;
                    using (BPMConnection cn = new BPMConnection())
                    {
                        cn.WebOpen();

                        User user = User.FromAccount(cn, uid);

                        switch (fieldName)
                        {
                        case "DisplayName":
                            user.DisplayName = strValue;
                            break;

                        case "HRID":
                            user.HRID = strValue;
                            break;

                        case "Mobile":
                            user.Mobile = strValue;
                            break;

                        case "OfficePhone":
                            user.OfficePhone = strValue;
                            break;

                        case "HomePhone":
                            user.HomePhone = strValue;
                            break;

                        case "EMail":
                            user.EMail = strValue;
                            break;

                        case "Office":
                            user.Office = strValue;
                            break;

                        case "Birthday":
                            if (DateTime.TryParse(strValue, out date))
                            {
                                user.Birthday = date;
                            }
                            else
                            {
                                user.Birthday = DateTime.MinValue;
                            }
                            break;

                        case "DateHired":
                            if (DateTime.TryParse(strValue, out date))
                            {
                                user.DateHired = date;
                            }
                            else
                            {
                                user.DateHired = DateTime.MinValue;
                            }
                            break;
                        }

                        User.Update(cn, uid, user);
                    }
                }
                else
                {
                    throw new Exception(String.Format(JosonStrings.Aspx_UnknowCommand, method));
                }

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

                rv.Attributes.Add("success", true);
                context.Response.Write(rv.ToString());
            }
            catch (Exception e)
            {
                JsonItem rv = new JsonItem();
                rv.Attributes.Add("success", false);
                rv.Attributes.Add("errorMessage", e.Message);
                context.Response.Write(rv.ToString());
            }

            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";
        }
Exemple #13
0
        protected virtual string GetFilterStringWorklist(YZRequest request, IYZDbProvider provider)
        {
            string filter = null;

            string searchType = request.GetString("SearchType", null);
            string keyword    = request.GetString("Kwd", null);

            string serialNumLike    = null;
            string processNameLike  = null;
            string ownerAccountLike = null;
            string agentAccountLike = null;
            string stepNameLike     = null;
            string descriptionLike  = null;
            string taskidEqu        = null;

            string specProcessName = request.GetString("SpecProcessName", null);

            if (!String.IsNullOrEmpty(specProcessName))
            {
                string[] processNames      = specProcessName.Split(',');
                string   processNameFilter = null;
                foreach (string processName in processNames)
                {
                    if (String.IsNullOrEmpty(processName))
                    {
                        continue;
                    }

                    processNameFilter = provider.CombinCondOR(processNameFilter, String.Format("ProcessName=N'{0}'", provider.EncodeText(processName)));
                }

                filter = provider.CombinCond(filter, processNameFilter);
            }

            if (!String.IsNullOrEmpty(keyword))
            {
                serialNumLike    = String.Format("SerialNum LIKE(N'%{0}%')", provider.EncodeText(keyword));
                processNameLike  = String.Format("ProcessName LIKE(N'%{0}%')", provider.EncodeText(keyword));
                ownerAccountLike = String.Format("OwnerAccount LIKE(N'%{0}%')", provider.EncodeText(keyword));
                agentAccountLike = String.Format("AgentAccount LIKE(N'%{0}%')", provider.EncodeText(keyword));
                stepNameLike     = String.Format("NodeName LIKE(N'%{0}%')", provider.EncodeText(keyword));
                descriptionLike  = String.Format("Description LIKE(N'%{0}%')", provider.EncodeText(keyword));
                if (YZStringHelper.IsNumber(keyword))
                {
                    taskidEqu = String.Format("TaskID={0}", keyword);
                }
            }

            if (YZStringHelper.EquName(searchType, "AdvancedSearch"))
            {
                string processName     = request.GetString("ProcessName", null);
                string postUserAccount = request.GetString("PostUserAccount", null);
                string periodType      = request.GetString("PostDateType", "").ToLower();
                string taskId          = request.GetString("TaskID", null);
                string serialNum       = request.GetString("SerialNum", null);

                string keywordFilter = null;

                if (!String.IsNullOrEmpty(processName))
                {
                    filter = provider.CombinCond(filter, String.Format("ProcessName=N'{0}'", provider.EncodeText(processName)));
                }
                else
                {
                    keywordFilter = provider.CombinCondOR(keywordFilter, processNameLike);
                }

                if (!String.IsNullOrEmpty(postUserAccount))
                {
                    filter = provider.CombinCond(filter, String.Format("OwnerAccount=N'{0}' OR AgentAccount=N'{0}'", provider.EncodeText(postUserAccount)));
                }
                else
                {
                    keywordFilter = provider.CombinCondOR(keywordFilter, ownerAccountLike);
                    keywordFilter = provider.CombinCondOR(keywordFilter, agentAccountLike);
                }

                DateTime date1 = DateTime.MinValue;
                DateTime date2 = DateTime.MaxValue;
                if (periodType != "all")
                {
                    date1 = request.GetDateTime("PostDate1", DateTime.MinValue);
                    date2 = request.GetDateTime("PostDate2", DateTime.MinValue);
                }

                if (date1 != DateTime.MinValue)
                {
                    filter = provider.CombinCond(filter, provider.GenPeriodCond("CreateAt", date1, date2));
                }

                if (!String.IsNullOrEmpty(taskId) && YZStringHelper.IsNumber(taskId))
                {
                    filter = provider.CombinCond(filter, String.Format("TaskID={0}", taskId));
                }
                else
                {
                    keywordFilter = provider.CombinCondOR(keywordFilter, taskidEqu);
                }

                if (!String.IsNullOrEmpty(serialNum))
                {
                    filter = provider.CombinCond(filter, String.Format("SerialNum LIKE(N'{0}%')", provider.EncodeText(serialNum)));
                }
                else
                {
                    keywordFilter = provider.CombinCondOR(keywordFilter, serialNumLike);
                }

                keywordFilter = provider.CombinCondOR(keywordFilter, stepNameLike);
                keywordFilter = provider.CombinCondOR(keywordFilter, descriptionLike);

                filter = provider.CombinCond(filter, keywordFilter);
            }

            if (YZStringHelper.EquName(searchType, "QuickSearch"))
            {
                string processName   = request.GetString("ProcessName", null);
                string keywordFilter = null;

                if (!String.IsNullOrEmpty(processName))
                {
                    filter = provider.CombinCond(filter, String.Format("ProcessName=N'{0}'", provider.EncodeText(processName)));
                }
                else
                {
                    keywordFilter = provider.CombinCondOR(keywordFilter, processNameLike);
                }

                keywordFilter = provider.CombinCondOR(keywordFilter, taskidEqu);
                keywordFilter = provider.CombinCondOR(keywordFilter, serialNumLike);
                keywordFilter = provider.CombinCondOR(keywordFilter, ownerAccountLike);
                keywordFilter = provider.CombinCondOR(keywordFilter, agentAccountLike);
                keywordFilter = provider.CombinCondOR(keywordFilter, stepNameLike);
                keywordFilter = provider.CombinCondOR(keywordFilter, descriptionLike);
                filter        = provider.CombinCond(filter, keywordFilter);
            }

            return(filter);
        }