Пример #1
0
        public static string GetJson(DBgl_UserInfoCollection itemCollection)
        {
            StringBuilder builder = new StringBuilder();

            if (itemCollection.Count > 0)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                System.IO.StringWriter    sw = new System.IO.StringWriter(sb);
                using (JsonWriter jsonWriter = new JsonTextWriter(sw))
                {
                    jsonWriter.Formatting = Formatting.Indented;
                    jsonWriter.WriteStartObject();
                    jsonWriter.WritePropertyName("results");
                    jsonWriter.WriteStartArray();
                    itemCollection.ForEach(delegate(DBgl_UserInfo objItem)
                    {
                        jsonWriter.WriteStartObject();
                        jsonWriter.WritePropertyName("UserInfId");
                        jsonWriter.WriteValue(objItem.UserInfId.ToString());
                        jsonWriter.WritePropertyName("UserId");
                        jsonWriter.WriteValue(objItem.UserId.ToString());
                        jsonWriter.WritePropertyName("UserName");
                        jsonWriter.WriteValue(objItem.UserName.ToString());
                        jsonWriter.WritePropertyName("CreatedDate");
                        jsonWriter.WriteValue(objItem.CreatedDate.ToString());
                        jsonWriter.WritePropertyName("Mobile");
                        jsonWriter.WriteValue(objItem.Mobile.ToString());
                        jsonWriter.WritePropertyName("CountryId");
                        jsonWriter.WriteValue(objItem.CountryId.ToString());
                        //jsonWriter.WritePropertyName("LocationId");
                        //jsonWriter.WriteValue(objItem.LocationId.ToString());
                        jsonWriter.WritePropertyName("Address");
                        jsonWriter.WriteValue(objItem.Address.ToString());
                        jsonWriter.WritePropertyName("Rating");
                        jsonWriter.WriteValue(objItem.Rating.ToString());
                        jsonWriter.WritePropertyName("MyLegs");
                        jsonWriter.WriteValue(objItem.MyLegs.ToString());
                        jsonWriter.WritePropertyName("EnjoyLegs");
                        jsonWriter.WriteValue(objItem.EnjoyLegs.ToString());
                        jsonWriter.WritePropertyName("Sex");
                        jsonWriter.WriteValue(objItem.Sex.ToString());


                        jsonWriter.WritePropertyName("UserImg");
                        DBtblUser myUser;
                        string img = "no_image.gif";
                        myUser     = DBtblUserManager.GetItemByID(objItem.UserId);
                        if (myUser != null)
                        {
                            img = myUser.ImgUrl;
                        }
                        jsonWriter.WriteValue(img);

                        jsonWriter.WritePropertyName("createdUser");
                        jsonWriter.WriteValue(objItem.createdUser.ToString());

                        jsonWriter.WriteEndObject();
                    });
                    jsonWriter.WriteEndArray();

                    jsonWriter.WriteEndObject();
                    builder.AppendLine(sw.ToString());
                }
            }
            else
            {
                //   builder.AppendLine(@"{""results"":[{""id"":""-1"",""myvalue"":""" + MainFunction.ngonngu("gl.nodata") + @"""}]}");
            }
            return(builder.ToString());
        }
Пример #2
0
        public static DBgl_Workflow AddItem(int WStatus,
                                            DateTime CreatedDate,
                                            string CreatedUser,
                                            bool Published,
                                            string WorkflowName,
                                            string SmallDesc,
                                            DateTime FromDate,
                                            DateTime ToDate, decimal BudgetAmt, decimal ReceiveAmt, decimal PaymentAmnt, decimal CashOnHandAmt, int Members,
                                            bool isClose, int Ratting, string ImgUrl, int SharingType)
        {
            DBgl_Workflow item      = null;
            Database      db        = SqlHelper.CreateConnection(SqlHelper.MyConnection);
            DbCommand     dbCommand = db.GetStoredProcCommand("gl_Workflow_Add");

            db.AddOutParameter(dbCommand, "WorkflowID", DbType.Guid, 0);

            db.AddInParameter(dbCommand, "WStatus", DbType.Int32, WStatus);

            db.AddInParameter(dbCommand, "CreatedDate", DbType.DateTime, CreatedDate);

            db.AddInParameter(dbCommand, "CreatedUser", DbType.String, CreatedUser);

            db.AddInParameter(dbCommand, "Published", DbType.Boolean, Published);

            db.AddInParameter(dbCommand, "WorkflowName", DbType.String, HtmlTag.Strip(WorkflowName));

            db.AddInParameter(dbCommand, "SmallDesc", DbType.String, SmallDesc);

            db.AddInParameter(dbCommand, "FromDate", DbType.DateTime, FromDate);

            db.AddInParameter(dbCommand, "ToDate", DbType.DateTime, ToDate);
            db.AddInParameter(dbCommand, "BudgetAmt", DbType.Decimal, BudgetAmt);

            db.AddInParameter(dbCommand, "ReceiveAmt", DbType.Decimal, ReceiveAmt);

            db.AddInParameter(dbCommand, "PaymentAmnt", DbType.Decimal, PaymentAmnt);

            db.AddInParameter(dbCommand, "CashOnHandAmt", DbType.Decimal, CashOnHandAmt);
            db.AddInParameter(dbCommand, "Members", DbType.Int32, Members);

            db.AddInParameter(dbCommand, "isClose", DbType.Boolean, isClose);

            db.AddInParameter(dbCommand, "Ratting", DbType.Int32, Ratting);

            db.AddInParameter(dbCommand, "ImgUrl", DbType.String, ImgUrl);
            db.AddInParameter(dbCommand, "SharingType", DbType.Int32, SharingType);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                Guid itemID = (Guid)(db.GetParameterValue(dbCommand, "@WorkflowID"));
                item = GetItemByID(itemID);
                if (item != null)
                {
                    //add this user to Friend Request
                    DBtblUser          objUser    = DBtblUserManager.GetItemByUser(CreatedUser);
                    DBgl_FriendRequest objRequest = DBgl_FriendRequestManager.AddItem(objUser.Username, objUser.Username,
                                                                                      objUser.Email, Guid.NewGuid(), DateTime.Now,
                                                                                      objUser.Username, item.WorkflowID, true, true, false, 0, 0, "", (int)FriendRequestEnum.gl_Invited);
                    //UPdate USerInfo Legs
                    DBgl_UserInfo objInfo = DBgl_UserInfoManager.GetItemByUserName(CreatedUser);
                    if (objInfo != null)
                    {
                        int joinlegs    = objInfo.MyLegs + 1;
                        int myenjoyLegs = objInfo.EnjoyLegs + 1;
                        objInfo = DBgl_UserInfoManager.UpdateItem(objInfo.UserInfId, objInfo.UserId,
                                                                  objInfo.UserName, objInfo.CreatedDate, objInfo.Mobile, objInfo.CountryId, objInfo.LocationId, objInfo.Address,
                                                                  objInfo.Rating, joinlegs, myenjoyLegs, objInfo.Sex, objInfo.createdUser);
                    }
                    RemoveCache(item);
                }
            }
            return(item);
        }